Fread fprintf text file issue

Hello guys,
I have a problem I wish you can help me fix.
I have written a .txt file using fprintf. So everything is formatted as I wanted in the file. The advantage of using fprintf in my code is that I used format specifiers to print (write) values of variables at run tim in the file... Brief the problem is that
now I need to put ALL the content of the text file into a  buffer pointed to by a (char * ) so that I can use that buffer in a pdfLibrary function (libHaru)... BUT since I used fprintf, fread doesnt function properly an I get "garbage"
in the (char * )  pointer and the buffer it points to. I failed when trying to use fscanf. I'll put my code here but.
Below a piece of my code. Hopefully you'll see through it.
Could you guys help me to find a way around this problem ?
Another problem is I MUST use fprintf instead of fwrite since I write values (using format specifiers) of variables a run time AND I need the output to be formatted so libHaru will just blindly prind the text to a pdf page.
void main(void)
FILE *fp;
char *myfile_text;
fp = fopen("myfile.txt", "r");
//myfile.txt was written with fprintf
fseek(fp, 0, SEEK_END);
myfile_size = ftell(fp);
myfile_text = (char*)malloc(sizeof(char)*myfile_size);
fread(myfile_text, sizeof(char), myfile_size, fp);
//fscanf(fp, "%s", text); FAILED
puts(myfile_text); // DOES NOT PRINT THE TEXT
//libHaru code
HPDF_Page_BeginText(page);
hauteur_page = HPDF_Page_GetHeight(page);
/*myfile_text pointer utilisation*/HPDF_Page_TextOut(page, x, y, myfile_text);
HPDF_Page_EndText(page);
HPDF_SaveToFile(pdfDoc, "test.pdf");
fclose(fp);
free(myfile_text);

This is obviously not the code you executed.  For example, there is no definition of myfile_size.  If your code is not doing what you expect, you need to show us the code that executed.  It's OK, even desirable, to strip your function
down to the minimum that demonstrates the problem but then you need to compile and execute that stripped down version.  Otherwise, we are comparing apples and oranges.  However, it is all we have to talk about now, so-
How did you determine that the file was written correctly?
Consider that fread() probably returned 0.  Since you positioned the file pointer at the end of the file, there was nothing left to read.  What would you expect puts() to produce in this case?
fp is opened as a text file.  The description of ftell() warns that the return value is not necessarily a character count.
One common method of reading a text file of unknown size into a buffer is:
     Determine a "reasonable" initial size for the buffer and a "reasonable" increment if the file is larger.
     Allocate the initial size.
     Attempt to read that many characters.
     If you read less:
          You are done.
          If you want, you can free the excess by reallocating the buffer to just this size.
     Loop until you read less than requested (or the expansion fails):
          Use realloc() to expand the buffer by the increment
          Attempt to read that many more characters at the end of the current data.
          Repeat.
If you are going to pass the buffer to puts(), you need to add the '\0' termination character at the end of the data to make it a well formed string.  fread() does not do this for you like some other functions.
Since you are coding in C:
     main() returns int.  Always.
     You don't need to cast the return value of malloc().
     sizeof(char) is guaranteed to be 1.

Similar Messages

  • Text file issue

    Hi,
    I can read numbers from text file and input them into an array, BUT how do i read one number and put that in a element of the array .Then read another number and put it in the next column of the 2D array.
    eg 50, 41
    The array will have 50 in the first element and the second element in the array will be 41 etc
    thank you
    mik reid

    I'm not sure what you mean because in your first sentence you say you do know how to read a file into an array and in the second sentence you ask how to read a file and put it into an array. If you file is of the format:
    50,41
    52,42
    Then Read From Spreadsheet will create a 2D array with 50 in row 0, column 0, 41 in row 0, column 1, 52 in row 1, column 0, 42 in row 1, column 1.
    If your data is of the format:
    50,41,52,42
    Then you can use Read From Spreadsheet, take the 1D array output and use Reshape Array to create a 2D array like in the attachment.
    Attachments:
    Reshape Array.JPG ‏6 KB

  • Read in text file issue

    I'm working on a command line address book that reads in a file and then writes out a file. It won't read in the file (addbook.txt). I haven't tried the write out file. From everything I've been able to find...this is supposed to work. What am I missing?
    Thanks in advance.
    Steve
    public void fileOpener() throws IOException
         try
              FileReader fr = new FileReader("addbook.txt");
              BufferedReader br = new BufferedReader(fr);
              String s;
              while((s = br.readLine()) != null)
                   System.out.println(s);
              fr.close();
         catch (IOException e)
              System.out.println("There was an error opening the file. Error: " + e);
    }

    Just for your own info, you may want to run the following snippet to determine what the current directory is! This is the directory that your code is looking in. The other responses to this post were correct, however, I think most people get bitten by this one at some point!
    System.out.println(new java.io.File(".").getAbsolutePath());

  • Issue when exporting data to text file in BI Publisher 10.1.3.4

    We are trying to export over 900,000 records to a text file from BI Publisher. The reports keep on running while scheduling. But if we reduce the record limit to 200,000 it works fine. Please help us to resolve this issue. Its really urgent.

    How are you doing it? With a template? Need more info to be able to help
    Tim

  • Webutil - issue with uploading text files with client_get_file_name

    Hi,
    I'm using webutil client_get_file_name to upload files from the client machine to the server.
    It works fine for xls,pdf,doc files etc. but not for txt files it seems.
    It doesn't display any error at all either.
    Has anyone seen this type of issue before?
    Kind regards,
    Tom
    Windows XP
    Forms v10.1.2.0.2

    Hi Sarah et al,
    The code that I'm using to upload any file type format is:
    vfilename := client_get_file_name('c:\',file_filter => 'All files (*.*)');
    it works for doc/pdf/xls/rtf/csv etc.
    but not for text files i.e. .txt
    Also, could someone tell me how to open a .msg (Outlook message) file
    as it gives the output:
    'Cannot read item' upon the opening of the Outlook application.
    I'm using the following to try and open it:
    CLIENT_HOST( 'cmd /C start '||p_filename);
    Your help would be appreciated.
    Kind regards,
    Tom

  • Write to text file while scrolling table issue

    Hi all,
    I have a LabVIEW application that logs data using 'write to text file' every second. This is a bckground task in a sub-VI. On the main screen I have several tables that have scrollbars. Every time the file is written the scrolling of a table is effectivley canceled. It is then necessary to click on the scrollbar again to re-start scrolling the table. I guess this is an issue with the OS but not sure yet. I have not tested other operating systems yet. I thought I would try the forum first. Has anyone else experienced this issue? Any ideas on how to fix this?
    I have tried using list boxes instead of tables but the same issue exists.
    I'm using windows 7 and LabVIEW 2011.
    Thank you.
    Certified LabVIEW Architect

    Hi Steve, thanks for offering to help. Right now I'm on a machine with LabVIEW 2010 and XP and the issue does not exist. But I have created a little test VI that should demonstrate the issue once running on LabVIEW 2011 SP1 and Windows 7. I can't confirm this VI will demonstrate the issue until later today when I can test it on the problem system myself. Feel free to give it a go and let us know what you find, or wait until I confirm the attached VI will demonsrate the issue (10 to 12 hrs time).
    Thank again.
    Certified LabVIEW Architect
    Attachments:
    Table scroll test_1.vi ‏13 KB

  • Scrolling through text file records issue?

    Hi there
    I am having an issue when trying to scroll though my saved contacts.
    On boot up they all work fine, and each record goes in its corresponding textfield. Now I cannot scroll left and right through the records, to display each new record.
    I tried making a marker at the end of each set, by putting a -1, -2 and so on per record, to distinguish the end of a record set. With the below however when I click right, and it just puts a -1 in the textfield??
    How do I get the program to distinguish the difference between the end of a record and the details of a new one?
    //This code is used at start up to read in the first record. This works fine.
    public TabbedPaneDemo()
    //BufferedReader br = null;
    BufferedReader no = null;
    Count = 0;
    try
    br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
    String s = "";
    while((s=br.readLine()) != null )
    Count = 1;
    //System.out.println("Data is " + s);
    inboundtext = s;
    if ( Count == 1 )
    //fdTitle.setText(inboundtext);
    fdTitle.setText(inboundtext);
    break;
    while((s=br.readLine()) != null )
    //System.out.println("Data is " + s);
    inboundtext = s;
    Count = 2;
    if ( Count == 2 )
    //fdTitle.setText(inboundtext);
    fdFirst.setText(inboundtext);
    break;
    //--------and so on tfor the rest
    //The code here is the problem. This is the button to scroll right through the records.
    else if (evt.getSource() == pane_butRIGHT)
    System.out.println("RIGHT");
    Aniversary = fdAniversary.getText();
    int test = Integer.parseInt(Aniversary);
    int setter = 4;
    try
    br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
    String s = "";
    while((s=br.readLine()) != null )
    Count = 1;
    inboundtext = s;
    //System.out.println(s);
    if ( inboundtext.equals("-1"))
    System.out.println("positive");
    //continue ;
    while((s=br.readLine()) != null )
    fdTitle.setText(inboundtext);
    fdFirst.setText(inboundtext);
    //break;
    catch(IOException ie)
    finally
    try
    if(br!=null) br.close();
    catch(Exception e)
    /* my text file I'm reading from below */
    mr
    lee
    smithers
    smith
    chappy
    [email protected]
    1 d road
    delta rd
    surrey
    kt4
    uk
    ww.vw.com
    337
    5791
    0781
    arm
    110 fb road
    cambs
    cambs
    cb1
    UK
    arm.com
    3rd line
    sysadmin
    410
    00
    00
    1
    2
    3
    4
    -1
    dr
    bob
    b
    bun
    cob
    [email protected]
    main st
    hamp
    ny
    14457
    ussa
    arse.com
    44
    00
    66
    piano inc
    main st
    rubbish
    5749
    duff
    usa
    abc.com
    yoyo
    billies
    desk
    222
    111
    00
    3
    69
    8
    7
    -2

    Hi camickr
    thanks for the responce,
    I understand what you saying with the stringtokenizer.
    However my text file would have loads of rows of contacts. My problem comes in where when I want to scroll through those rows, I need them to be display on my GUI which has a Jtextfield per contact detail type, IE one for name and another surname and so on.
    Now when the program loads, it reads in the first contact set fine. If I want to read the second contact set, I am stuck. Same again applies if I want to scroll back throgh the contacts? How do I do this?
    As you can see in the default constructor, there is a whole batch of while loops getting text initally for the JTextfields. If I could change this just to read the second through in and so on when hitting left or right, problem solved.
    thanks
    Whole program below:
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.awt.Graphics.*;
    import java.awt.Color.*;
    import javax.swing.JPanel.*;
    import javax.swing.JLabel;
    import java.awt.event.*;
    import javax.swing.text.html.*;
    import java.net.*;
    import java.net.URL.*;
    import java.io.IOException;
    import java.io.*;
    import java.awt.image.*;
    import javax.swing.border.*;
    import java.applet.*;
    import javax.swing.JEditorPane;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.tree.TreeSelectionModel;
    import javax.swing.JTabbedPane;
    import javax.swing.ImageIcon;
    import java.util.StringTokenizer;
    public class TabbedPaneDemo extends JPanel implements ActionListener
         JButton pane_butSave = new JButton();
    private JLabel lblTitle = new JLabel("tilte:" );
    private JLabel lblFirst = new JLabel("first:" );
    private JLabel lblMiddle = new JLabel("Middle:");
    private JLabel lblLast = new JLabel("Last:" );
    private JLabel lblNickName= new JLabel("nick name:" );
    private JLabel lblEmail= new JLabel("e-mail:" );
    private JTextField fdTitle = new JTextField(4);
    private JTextField fdFirst= new JTextField(15);
    private JTextField fdMiddle = new JTextField(15);
    private JTextField fdLast = new JTextField(20);
    private JTextField fdNickName = new JTextField(15);
    private JTextField fdEmail = new JTextField(50);
    private JLabel lblStreetAddress = new JLabel("Street Address");
    private JLabel lblCity = new JLabel("Town");
    private JLabel lblCounty = new JLabel("County");
    private JLabel lblCountry = new JLabel("Country");
    private JLabel lblPostCode = new JLabel("ZIP/Post");
    private JLabel lblWebpage = new JLabel("Web Page");
    private JLabel lblPhone = new JLabel("Phone");
    private JLabel lblFax = new JLabel("Fax");
    private JLabel lblMobile = new JLabel("Mobile");
    private JTextField fdStreetAddress = new JTextField();
    private JTextField fdCity = new JTextField ();
    private JTextField fdCounty = new JTextField ();
    private JTextField fdCountry = new JTextField ();
    private JTextField fdPostCode = new JTextField ();
    private JTextField fdWebpage = new JTextField ();
    private JTextField fdPhone = new JTextField ();
    private JTextField fdFax = new JTextField ();
    private JTextField fdMobile = new JTextField ();
    private JLabel lblCompany = new JLabel("Company");
    private JLabel lblCompanyAddress = new JLabel("Company Address");
    private JLabel lblCompanyCity = new JLabel("Town");
    private JLabel lblCompanyCounty = new JLabel("County");
    private JLabel lblCompanyPostCode = new JLabel("ZIP/Post");
    private JLabel lblCompanyCountry = new JLabel("Country");
    private JLabel lblCompanyWebPage = new JLabel("Web Page");
    private JLabel lblJobTitle = new JLabel("JOB Title");
    private JLabel lblDepartment = new JLabel("Department");
    private JLabel lblOffice = new JLabel("Office");
    private JLabel lblCompanyPhone = new JLabel("Phone");
    private JLabel lblCompanyFax = new JLabel("Fax");
    private JLabel lblPager = new JLabel("Pager");
    private JLabel lblCompanyIPphone = new JLabel("IP Phone");
    private JTextField fdCompany = new JTextField ();
    private JTextField fdCompanyAddress = new JTextField ();
    private JTextField fdCompanyCity = new JTextField ();
    private JTextField fdCompanyCounty = new JTextField ();
    private JTextField fdCompanyPostCode = new JTextField ();
    private JTextField fdCompanyCountry = new JTextField ();
    private JTextField fdCompanyWebPage = new JTextField ();
    private JTextField fdJobTitle = new JTextField ();
    private JTextField fdDepartment = new JTextField ();
    private JTextField fdOffice = new JTextField ();
    private JTextField fdCompanyPhone = new JTextField ();
    private JTextField fdCompanyFax = new JTextField ();
    private JTextField fdPager = new JTextField ();
    private JTextField fdCompanyIPphone = new JTextField ();
    private JLabel lblSpouse = new JLabel("Spouse");
    private JLabel lblGender = new JLabel("Gender");
    private JLabel lblBirthday = new JLabel("Birthday");
    private JLabel lblAniversary = new JLabel("Aniversary");
    private JTextField fdSpouse = new JTextField ();
    private JTextField fdGender = new JTextField ();
    private JTextField fdBirthday = new JTextField ();
    private JTextField fdAniversary = new JTextField ();
    private JLabel lblNotes = new JLabel("Other Notes");
    private JTextArea taNotes = new JTextArea ();
    private ImageIcon imaNameInfo = new ImageIcon("nameinfo.gif");
    private JLabel lblNameInfo = new JLabel(imaNameInfo);
    private ImageIcon imaHomeInfo = new ImageIcon("homeinfo.gif");
    private JLabel lblHomeInfo = new JLabel(imaHomeInfo);
    private ImageIcon imaBusinessInfo = new ImageIcon("businessinfo.gif");
    private JLabel lblBusinessInfo = new JLabel(imaBusinessInfo);
    private ImageIcon imaPersonalInfo = new ImageIcon("personal.gif");
    private JLabel lblPersonalInfo = new JLabel(imaPersonalInfo);
    private ImageIcon imaOtherInfo = new ImageIcon("otherinfo.gif");
    private JLabel lblOtherInfo = new JLabel(imaOtherInfo);
    private JButton pane_butAddOK = new JButton("Ok");
    private JButton pane_butAddCANCEL = new JButton("Exit");
    //private JButton pane2_butAddOK = new JButton("Ok");
    private JButton pane2_butAddCANCEL = new JButton("Exit");
    //private JButton pane3_butAddOK = new JButton("Ok");
    private JButton pane3_butAddCANCEL = new JButton("Exit");
    //private JButton pane4_butAddOK = new JButton("Ok");
    private JButton pane4_butAddCANCEL = new JButton("Exit");
    //private JButton pane5_butAddOK = new JButton("Ok");
    private JButton pane5_butAddCANCEL = new JButton("Exit");
    private ImageIcon imaLeft = new ImageIcon("left.gif");
    private ImageIcon imaRight = new ImageIcon("right.gif");
    private JButton pane_butLEFT = new JButton(imaLeft);
    private JButton pane_butRIGHT = new JButton(imaRight);
    private JButton pane2_butLEFT= new JButton(imaLeft);
    private JButton pane2_butRIGHT= new JButton(imaRight);
    private JButton pane3_butLEFT = new JButton(imaLeft);
    private JButton pane3_butRIGHT = new JButton(imaRight);
    private JButton pane4_butLEFT = new JButton(imaLeft);
    private JButton pane4_butRIGHT = new JButton(imaRight);
    private JButton pane5_butLEFT = new JButton(imaLeft);
    private JButton pane5_butRIGHT = new JButton(imaRight);
    private JButton pane_butNEW= new JButton("Reset");
    private JButton pane2_butNEW = new JButton("Reset");
    private JButton pane3_butNEW = new JButton("Reset");
    private JButton pane4_butNEW = new JButton("Reset");
    private JButton pane5_butNEW = new JButton("Reset");
    private JTabbedPane tabbedPane = new JTabbedPane();
    private RandomAccessFile raf;
                   String inboundtext;
                   String Title, First, Middle, Last, NickName, Email;
                   String Address, Town, County, PostCode, Country, Phone, Fax,
                        Mobile, Webpage;
                   String Company, CompanyAddress, CompanyTown, CompanyCounty, CompanyPostCode,
                        CompanyCountry, Job, Department, Office, CompanyPhone, CompanyFax,
                        CompanyPager,CompanyIPPhone, CompanyWebpage;
                   String Spouse, Gender, Birthday, Aniversary;
                   String Notes;
                   public JTextArea area = new JTextArea();
                   BufferedReader br = null;
                   int Count;
    public TabbedPaneDemo()
              pane_butSave .setVerticalTextPosition(SwingConstants.BOTTOM);
                   pane_butSave .setHorizontalTextPosition(SwingConstants.CENTER);
              pane_butSave .setText("<html><center>"+"Update "+"<br>"+"Changes"+"</center></html>");
              pane_butAddOK .setVerticalTextPosition(SwingConstants.BOTTOM);
                   pane_butAddOK .setHorizontalTextPosition(SwingConstants.CENTER);
              pane_butAddOK .setText("<html><center>"+"New "+"<br>"+"Contact"+"</center></html>");
         //BufferedReader br = null;
         BufferedReader no = null;
         Count = 0;
         try
              br = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\filename.txt")));
              String s = "";
              while((s=br.readLine()) != null )
                   Count = 1;     
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   if ( Count == 1 )
                        //fdTitle.setText(inboundtext);
                        fdTitle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 2;
                   if ( Count == 2 )
                        //fdTitle.setText(inboundtext);
                        fdFirst.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 3;
                   if ( Count == 3 )
                        //fdTitle.setText(inboundtext);
                        fdMiddle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 4;
                   if ( Count == 4 )
                        //fdTitle.setText(inboundtext);
                        fdLast.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 5;
                   if ( Count == 5 )
                        //fdTitle.setText(inboundtext);
                        fdNickName.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 6;
                   if ( Count == 6 )
                        //fdTitle.setText(inboundtext);
                        fdEmail.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 7;
                   if ( Count == 7 )
                        //fdTitle.setText(inboundtext);
                        fdStreetAddress.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 8;
                   if ( Count == 8 )
                        //fdTitle.setText(inboundtext);
                        fdCity.setText(inboundtext);
                        break;
         while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 9;
                   if ( Count == 9 )
                        //fdTitle.setText(inboundtext);
                        fdCounty.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 10;
                   if ( Count == 10 )
                        //fdTitle.setText(inboundtext);
                        fdCountry.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 11;
                   if ( Count == 11 )
                        //fdTitle.setText(inboundtext);
                        fdPostCode.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 12;
                   if ( Count == 12 )
                        //fdTitle.setText(inboundtext);
                        fdWebpage.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 13;
                   if ( Count == 13 )
                        //fdTitle.setText(inboundtext);
                        fdPhone.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 14;
                   if ( Count == 14 )
                        //fdTitle.setText(inboundtext);
                        fdFax.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 15;
                   if ( Count == 15 )
                        //fdTitle.setText(inboundtext);
                        fdMobile.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 16;
                   if ( Count == 16 )
                        //fdTitle.setText(inboundtext);
                        fdCompany.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 17;
                   if ( Count == 17 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyAddress.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 18;
                   if ( Count == 18 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCity.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 19;
                   if ( Count == 19 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCounty.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyPostCode.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyCountry.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 20;
                   if ( Count == 20 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyWebPage.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 21;
                   if ( Count == 21 )
                        //fdTitle.setText(inboundtext);
                        fdJobTitle.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 22;
                   if ( Count == 22 )
                        //fdTitle.setText(inboundtext);
                        fdDepartment.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 23;
                   if ( Count == 23 )
                        //fdTitle.setText(inboundtext);
                        fdOffice.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 24;
                   if ( Count == 24 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyPhone.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 25;
                   if ( Count == 25 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyFax.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 26;
                   Company = fdCompany.getText();
                   String comp = Company;
                   //System.out.println(Company);
                   if ( Count == 26 )
                        //fdTitle.setText(inboundtext);
                        fdPager.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 27;
                   if ( Count == 27 )
                        //fdTitle.setText(inboundtext);
                        fdCompanyIPphone.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 28;
                   if ( Count == 28 )
                        //fdTitle.setText(inboundtext);
                        fdSpouse.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 29;
                   if ( Count == 29 )
                        //fdTitle.setText(inboundtext);
                        fdGender.setText(inboundtext);
                        break;
                   while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 30;
                   if ( Count == 30 )
                        //fdTitle.setText(inboundtext);
                        fdBirthday.setText(inboundtext);
                        break;
              while((s=br.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = s;
                   Count = 31;
                   if ( Count == 31 )
                        //fdTitle.setText(inboundtext);
                        fdAniversary.setText(inboundtext);
                        break;
              no = new BufferedReader(new InputStreamReader(new FileInputStream("\\c:\\notes.txt")));
              String n = "";
              while((n=no.readLine()) != null )
                   //System.out.println("Data is " + s);
                   inboundtext = n;
                   Count = 32;
                        //taNotes.setText(inboundtext);
                        taNotes.append(n + '\n' );
                        First delete notes.txt
                                  You always want to take a mirror image of what is in the box at that time
                                  save that that to a new notes.txt*/
         catch(IOException ie)
         finally
              try
                   if(br!=null) br.close();
              catch(Exception e)
    File name = new File("\\c:\\filename.txt");
              if( name.isFile() )
                   try
                        BufferedReader input = new BufferedReader( new FileReader( name ) );
                        StringBuffer buffer = new StringBuffer();
                        String text;
                        while (( text = input.readLine() ) != null )
                        buffer.append( text + "\n" );
                        //buffer.append( buffer.toString() );
                        System.out.println(buffer);
                        inBoundtext.append( buffer.toString() );
                   catch( IOException ioException )
                        JOptionPane.showMessageDialog( this, "FILE ERROR", "FILE ERROR", JOptionPane.ERROR_MESSAGE );
         setLayout(new GridLayout(1,1));
              JPanel pane = new JPanel();
              pane.setLayout(null);
    //--------------NAME PANEL START----------------------------------------
         lblNameInfo.setBounds(10, 10, 500, 50);
         pane.add(lblNameInfo);
         lblFirst.setBounds(20, 60 ,50 ,50);
              pane.add(lblFirst);
              fdFirst.setBounds(60, 70, 70, 30);
              pane.add(fdFirst);
              lblMiddle.setBounds(150, 60 ,50 ,50);
              pane.add(lblMiddle);
              fdMiddle.setBounds(200, 70, 70, 30);
              pane.add(fdMiddle);
              lblLast.setBounds(300, 60 ,50 ,50);
    pane.add(lblLast);
    fdLast.setBounds(350, 70, 70, 30);
              pane.add(fdLast);
              lblTitle.setBounds(20, 100 ,50 ,50);
                   pane.add(lblTitle);
              fdTitle.setBounds(60, 110, 70, 30);
              pane.add(fdTitle);
              lblNickName.setBounds(150, 100, 70,50);
              pane.add(lblNickName);
              fdNickName.setBounds(220, 110, 70, 30);
              pane.add(fdNickName);
              lblEmail.setBounds(20,160, 100, 50);
              pane.add(lblEmail);
              fdEmail.setBounds(70, 170, 210,30);
              pane.add(fdEmail);
              pane_butLEFT.setBounds(10, 400, 50, 40);
              pane.add(pane_butLEFT);
    pane_butRIGHT.setBounds(450, 400, 50, 40);
    pane.add(pane_butRIGHT);
              pane_butAddOK.setBounds(160, 400, 70, 50);
              pane.add(pane_butAddOK);
              pane_butAddCANCEL.setBounds(240, 400, 90, 40);
              pane.add(pane_butAddCANCEL);
              pane_butSave.setBounds(340,400, 90, 40);
              pane.add(pane_butSave);
              pane_butNEW.setBounds(80, 400, 70, 40);
              pane.add(pane_butNEW);
              tabbedPane.addTab("Name", null, pane, "Name Information");
    tabbedPane.setSelectedIndex(0);
    //--------------NAME PANEL END----------------------------------------
    //--------------HOME PANEL START----------------------------------------
    JPanel pane2 = new JPanel();
    pane2.setLayout(null);
    //pane2.setLayout(new GridLayout(6, 6, 10, 10));
    tabbedPane.addTab("Home", null, pane2, "Home Information");
                   lblHomeInfo.setBounds(10, 10, 500, 50);
         pane2.add(lblHomeInfo);
         lblStreetAddress.setBounds(10, 60 ,100 ,50);
              pane2.add(lblStreetAddress);
              fdStreetAddress.setBounds(100, 70, 150, 30);
              pane2.add(fdStreetAddress);     
              lblCity.setBounds(10, 90 ,100 ,50);
              pane2.add(lblCity);
              fdCity.setBounds(100, 100, 100, 30);
              pane2.add(fdCity);
                   lblCounty.setBounds(10, 120 ,100 ,50);
              pane2.add(lblCounty);
              fdCounty.setBounds(100, 130, 100, 30);
              pane2.add(fdCounty);
              lblCountry.setBounds(10, 150 ,100 ,50);
              pane2.add(lblCountry);
              fdCountry.setBounds(100, 160, 100, 30);
              pane2.add(fdCountry);
              lblPostCode.setBounds(10, 180 ,100 ,50);
              pane2.add(lblPostCode);
              fdPostCode.setBounds(100, 190, 100, 30);
              pane2.add(fdPostCode);
              lblWebpage.setBounds(10, 250 ,100 ,50);
              pane2.add(lblWebpage);
              fdWebpage.setBounds(100, 260, 330, 30);
              pane2.add(fdWebpage);
              lblPhone.setBounds(270, 60 ,100 ,50);
              pane2.add(lblPhone);
              fdPhone.setBounds(310, 70, 100, 30);
              pane2.add(fdPhone);
              lblFax.setBounds(270, 90 ,100 ,50);
              pane2.add(lblFax);
              fdFax.setBounds(310, 100, 100, 30);
              pane2.add(fdFax);
              lblMobile.setBounds(270, 120,100 ,50);
              pane2.add(lblMobile);
              fdMobile.setBounds(310, 130, 100, 30);
              pane2.add(fdMobile);
                   pane2_butLEFT.setBounds(10, 400, 50, 40);
              pane2.add(pane2_butLEFT);
    pane2_butRIGHT.setBounds(450, 400, 50, 40);
    pane2.add(pane2_butRIGHT);
    /* pane2_butAddOK.setBounds(180, 400, 50, 40);
              pane2.add(pane2_butAddOK);*

  • Loading a text file into a global variable issue - really a global var?

    From all the documentation and examples I can find, it appears that it would be
    correct to create a global array variable [outside of any functions] to load image names into,
    then use these images for a slideshow. I want to make the app dynamic, in that changing the text file gives a new set of images.
    The global variable goes null [no values] after the load event listener. Why is that?
    Isn't global, well global, and alive for the duration of the SWF?
    PARAMS.TXT:
    monthNames=January,February,March,April,May,June,July,August,September,October,November,De cember&dayNames=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
    CODE:
    var dNames:Array = new Array();
    var mNames:Array = new Array();
    var request:URLRequest = new URLRequest("images/params.txt");
    var variables:URLLoader = new URLLoader();
    variables.dataFormat = URLLoaderDataFormat.VARIABLES;
    variables.addEventListener(Event.COMPLETE, completeHandler);
    try
    variables.load(request);
    catch (error:Error)
    trace("Unable to load URL: " + error);
    trace("2 mNames 2: " + mNames[2]);
    trace("2 dNames 3: " + dNames[3]);
    stop();
    function completeHandler(event:Event):void
    var loader:URLLoader = URLLoader(event.target);
    dNames = loader.data.dayNames.split(",");
    mNames = loader.data.monthNames.split(",");
    trace(loader.data.dayNames);
    trace("1 mNames 2: " + mNames[2]);
    trace("1 dNames 3: " + dNames[3]);
    OUTPUT:
    2 mNames 2: undefined
    2 dNames 3: undefined
    Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
    1 mNames 2: March
    1 dNames 3: Wednesday
    How do I access these values after loading from the external file, after the load?
    Thanks in advance.

    The statement you quoted from whatever Adobe documentation is correct.
    If you want to load the data into the arrays before anything else happens, then have anything else that happens execute via the completeHandler function... after the data is loaded and processed into the arrays.
    the command: loadFile() executes before the trace("2:" +images[4]); command.  The loadFile function is processed and the loading process BEGINS... but starting the loading does not delay the main processing from continuing down the line--the loading itself becomes a secondary/background task.  The command was to execute the loadFile function and the processing of that function was completed.  If you don't believe so, then add a trace...
    function loadFile():void
         vars.dataFormat = URLLoaderDataFormat.VARIABLES;
         vars.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
         vars.load(new URLRequest("images/fnames.txt"));
         trace("started loading");
    If you add that trace, you should see that the loadFile function execution is completed and the next line in your code is then processed... trace(2....)
    The addEventlistener does not stop anything.  The addEventListener code is assigning a monitor, not a traffic controller... it is telling the monitor to indicate when the data has finished loading.  It is not telling anything to stop program execution.
    So if you want to wait until the data is loaded before you do anything else... it goes....
    function onComplete(evt:Event):void
         var urlVars:URLVariables = evt.target.data;
         images = vars.data.images.split(",");
         tnails = vars.data.thumbnails.split(",");
         ................HERE.................

  • Issue in Multiload script and import text file format

    I am using text output file from essbase to be imported to HFM using multiload
    The separator is tab for records.
    It seems i need to use tab separator in row 6 of text file (multiload) for dimension tags because separator should be same as in data records
    Is this true?
    When i am using Tab as separator for row 6 also ,no data gets loaded using multiload.
    But when i convert my file separator and row6 separator as comma then it works.
    But i need to use tab separator.
    Second point is i need to replace #MI with 0in event ecript
    Will i need to create new file(with mi replced with 0) in event script to do the same

    The Seperator needs to be comma for a test based multiload as noted in the samples in the FDM Administrator Guide.

  • Issue : Read a text file and print the same

    Hi, My requirement is to read a text file and print it the same way.
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              text += line;
              line = reader.readLine();
         System.out.println(text);
    The text file i used contains
    A
    B
    C
    but my output is ABC.
    What change should be made to print it the same way in the txt file ?

    Hi EJP,
    I modified the code based on your suggestion and now its working as expected. Thanks
    Modified code :
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              System.out.println(line);
              line = reader.readLine();
              text += line;
    }

  • Issues with cs5.0.03- cannot use CUDA, cannot find cuda support text file

    Hi,
    I am working with a big project and recently upgraded my video card to a GTX 570.
    I cannot enable the CUDA engine in project settings, it is completely greyed out..  Doing some searches, everyone seems to point at a cuda support text file...
    Kicker 2-
    I go to the Root directory of where adobe is installed, see the CS5 folder- with NO Cuda supported list.... Do a complete search of the whole machine, nothing.
    Updated adobe, no change
    Most up to date video drivers from Nvidia are already installed. 
    Went through Nvidia control panel to manually set it to render using the GPU- no change...
    I am at a loss here, any ideas or help would be much appreciated.

    Hello,
    Thank you for your time-
    Ok, I remoted back into the machine and took a closer look again,  Somehow half of the CS5 suite is on the C drive, and the other is on the storage- CS5 primarly. How I personally do not know, but from there was able to locate the needed folders, and created the text file.  All is well now, I just told them to finish the project first, before we move it over where it belongs.
    Joe Bloe P. Thank you very much.

  • Arbitrary waveform generation from large text file

    Hello,
    I'm trying to use a PXI 6733 card hooked up to a BNC 2110 in a PXI 1031-DC chassis to output arbitrary waveforms at a sample rate of 100kS/s.  The types of waveforms I want to generate are generally going to be sine waves of frequencies less than 10 kHz, but they need to be very high quality signals, hence the high sample rate.  Eventually, we would like to go up to as high as 200 kS/s, but for right now we just want to get it to work at the lower rate. 
    Someone in the department has already created for me large text files > 1GB  with (9) columns of numbers representing the output voltages for the channels(there will be 6 channels outputting sine waves, 3 other channels with a periodic DC voltage.   The reason for the large file is that we want a continuous signal for around 30 minutes to allow for equipment testing and configuration while the signals are being generated. 
    I'm supposed to use this file to generate the output voltages on the 6733 card, but I keep getting numerous errors and I've been unable to get something that works. The code, as written, currently generates an error code 200290 immediately after the buffered data is output from the card.  Nothing ever seems to get enqued or dequed, and although I've read the Labview help on buffers, I'm still very confused about their operation so I'm not even sure if the buffer is working properly.  I was hoping some of you could look at my code, and give me some suggestions(or sample code too!) for the best way to achieve this goal.
    Thanks a lot,
    Chris(new Labview user)

    Chris:
    For context, I've pasted in the "explain error" output from LabVIEW to refer to while we work on this. More after the code...
    Error -200290 occurred at an unidentified location
    Possible reason(s):
    The generation has stopped to prevent the regeneration of old samples. Your application was unable to write samples to the background buffer fast enough to prevent old samples from being regenerated.
    To avoid this error, you can do any of the following:
    1. Increase the size of the background buffer by configuring the buffer.
    2. Increase the number of samples you write each time you invoke a write operation.
    3. Write samples more often.
    4. Reduce the sample rate.
    5. Change the data transfer mechanism from interrupts to DMA if your device supports DMA.
    6. Reduce the number of applications your computer is executing concurrently.
    In addition, if you do not need to write every sample that is generated, you can configure the regeneration mode to allow regeneration, and then use the Position and Offset attributes to write the desired samples.
    By default, the analog output on the device does what is called regeneration. Basically, if we're outputting a repeating waveform, we can simply fill the buffer once and the DAQ device will reuse the samples, reducing load on the system. What appears to be happening is that the VI can't read samples out from the file fast enough to keep up with the DAQ card. The DAQ card is set to NOT allow regeneration, so once it empties the buffer, it stops the task since there aren't any new samples available yet.
    If we go through the options, we have a few things we can try:
    1. Increase background buffer size.
    I don't think this is the best option. Our issue is with filling the buffer, and this requires more advanced configuration.
    2. Increase the number of samples written.
    This may be a better option. If we increase how many samples we commit to the buffer, we can increase the minimum time between writes in the consumer loop.
    3. Write samples more often.
    This probably isn't as feasible. If anything, you should probably have a short "Wait" function in the consumer loop where the DAQmx write is occurring, just to regulate loop timing and give the CPU some breathing space.
    4. Reduce the sample rate.
    Definitely not a feasible option for your application, so we'll just skip that one.
    5. Use DMA instead of interrupts.
    I'm 99.99999999% sure you're already using DMA, so we'll skip this one also.
    6. Reduce the number of concurrent apps on the PC.
    This is to make sure that the CPU time required to maintain good loop rates isn't being taken by, say, an antivirus scanner or something. Generally, if you don't have anything major running other than LabVIEW, you should be fine.
    I think our best bet is to increase the "Samples to Write" quantity (to increase the minimum loop period), and possibly to delay the DAQmx Start Task and consumer loop until the producer loop has had a chance to build the queue up a little. That should reduce the chance that the DAQmx task will empty the system buffer and ensure that we can prime the queue with a large quantity of samples. The consumer loop will wait for elements to become available in the queue, so I have a feeling that the file read may be what is slowing the program down. Once the queue empties, we'll see the DAQmx error surface again. The only real solution is to load the file to memory farther ahead of time.
    Hope that helps!
    Caleb Harris
    National Instruments | Mechanical Engineer | http://www.ni.com/support

  • Export to Text file does not page

    Since I applied SP 7 for Crystal 9, when I export a report to a text file it does not page and print the report header on each page. It prints the report header once and one lone continuous page of information. My report was export to text with a page header on each page before I applied the service pack. How do I get it to page in the text export and print the page header on each page?

    In 8.5 the default behavior of the export to text was to not paginate. With 9 you have a paginate option when you manually export data to text, however when processing in batch 
    Mary Vertz wrote:
    export in the background
    you had no such option and it simply defaulted to 60 even for those reports that were suppressing the page header. This causes those text files to have a new-page marker at the start of every 62nd line. This causes the data on that line to be moved 1 character to the right and caused many issue with 8.5 backwards compatibility as this functionality was used for flat file interfaces for instance with the bank for positive pay.
    In SP7 they addressed this issue and changed the default behavior to not paginate and enabled a parameter to be passed to control pagination during batch processing.
    If that
    database application
    is PeopleSoft, the parameter that needs to be added to the process request is  -LN<number of lines> ex. -LN60
    Also note that the CPI can be set via the command line as well. For PeopleSoft it's -CPI<numerical value> which defaults to 12 if it isn't specified.
    Unfortunately I do not have the SP7 release notes handy to provide more detail on these options.
    Thanks
    Drew

  • Export to text file very, very slow

    Hi, I am running 2.1.0.63 and doing an export of a query to a text file. The export was 66000 rows, but took incredibly almost around 2 hours to finish. The row counter in the status bar was very slow. The same exact query/export under 1.5.4 ran in about 5 mins. The row counter on both the fetching and exporting was just flying by.
    Has anybody else experienced this ? What could be causing it to run that slow under this release ?
    The other issue I have is once there has been no activity for a while, sqldeveloper hangs has to be restarted. I saw this being addressed in another post however, and will follow it there.
    Any ideas on when a patch will be made available to this release ?
    BTW, I really like some of the other new features of this release.
    Thanks,
    Mark

    Ok, I think the issue was that I was exporting to a shared network drive. I redid it, saving it locally and it worked fine.
    I still have the issue of inactivity and having to restart sqldeveloper.
    Thanks.

  • Export to text file shows extra character at line 60, 120 so on

    Hi,
    I am using Crystal report 13 with .net 4.0 ( Visual Studio 2010)
    I have an issue while exporting from CR to Text file,
    After every 60 lines some special character is inserted in the text file. That might be the new page character.
    Is this the limitation of crystal report that the data is not shown is pages?
    If yes, if there any workaround for this?
    Can I set the pagination off for the report- either from .net code OR on the report itself so that I wonu2019t see the unwanted character?

    [CR for VS 2010 .NET SDK developer guide|http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_dg_2010_en.zip]
    [CR for VS 2010 API reference guide|http://help.sap.com/businessobject/product_guides/sapCRVS2010/en/crnet_api_2010_en.zip]
    See if this helps,
    Bhushan.

Maybe you are looking for