Announcement

Collapse
No announcement yet.

Writing multiple text files bug?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Writing multiple text files bug?

    I have written a small program to show 3 problems (bugs?) I have come across while programming my uLCD-32PT_GFX2. I am unable to write to multiple text files to a FAT16 formatted micro sd card. I have tested this with a few programs and when I look at the text file on my computer, I get the correct string written in one file and nothing (or garbage) in the other. Other problems shown in the program are:

    Image position read is incorrect (lines 50-51 in code), should be 55, 160
    Image dosn't show on the screen (lines 53)

    Please help!

    P.S. Remove .txt from the .Dat and .gci files and put them on the micro sd card. You can recreate them by opening Graphics Composer and adding the png.
    Attached files test.4dg (2 KB) test.Dat.txt (38 B) test.gci.txt (32.5 KB) test.gcs.txt (779 B)

  • #2


    I think the write to 'bal' might work a bit better if you had a close for it in the program.

    The version of GC you have writes the initial positioning in the .DAT file as decimal, it should be in hex

    i.e.
    "blue_arrow_up.png" 0000 0000 55 160

    should be
    "blue_arrow_up.png" 0000 0000 37 a0

    Try gc-for-dragondgold.zip in
    http://www.4dsystems.com.au/downloads/Graphics_Composer/Ver3.XX/
    Mark

    Comment


    • #3


      Thank you. That fixed both problems in that program! My original program still has a problem writing to multiple files, though. Could you please look at it?

      The relevant parts are as follows:
      I create buff and allocate memory to it on lines 68-69, open file balance.txt on 105, print a string to buff and write to file log.txt on 120-122, close balance.txt on 125, open file log.txt on 173, print a string to buff and write to file log.txt on 183-184, and close log.txt on 190. I found that if I comment out img_Show() lines in function, numpad(), it writes correctly to balance.txt, otherwise, I get something like the attached balance.txt.

      I would be very grateful if you could tell me what is wrong, as I have spend many hours trying to find the problem.
      -Nate
      Attached files BALANCE.TXT (60 B) keypad18a.4dg (9.5 KB) Keypad2.Dat.txt (669 B) Keypad2.Gci.txt (291.5 KB)

      Comment


      • #4


        Hmm, not quite sure how to drive the program, the quick try I had yielded a valid Balance.txt file.

        Can you reproduce this with the version 2.4 PmmC?
        Mark

        Comment


        • #5


          Thank yo so much!!
          I was running PmmC v.2.2. I upgraded to 2.4 and everything works fine!
          Thanks for the prompt and helpful support.
          -Nate

          Comment


          • #6
            One other question. Can you tell me how to get a string from my file, balance.txt and write it to an array? I understand I can only do this if the array is an array of pointers. The strings will be different sizes. I have been studying the sample program Picasso GFX2 > Picasso General > String1.4dg and cannot understand how this language uses pointers enough to write this code.

            This is what I want it to do:

            var m, i, buff;
            var catTotals[12];

            in main:
            if (balance := file_Open("balance.txt", 'r'))
            for(i:=0; i<12; i++)
            m := file_GetS(buff, 8, balance); // file_Gets return size read
            print("We read ", m , "bytes\n\n");
            to(catTotals[i]); print([STR] buff); // This line won't work, I must somehow use pointers
            //print( [STR] buff);
            //putstr(buff);
            next
            file_Close(balance);
            else
            print("Cant open file for reading");
            endif

            Comment

            Working...
            X