Announcement

Collapse
No announcement yet.

file_Write Question

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

  • file_Write Question

    Have say a 30 line text file that has been saved. I want to open the text file and write to line 17 and overwrite the text currently there. How would I go about doing this?
    Attempted to while(file_GetS(buff,10,file) != 0), but realized the GetS function does not work when opening a file for writing.

    thanks

  • #2


    You need to open the file in append mode and, probably use file_Seek.

    I presume you can also use file_GetS in append mode.

    I also presume you have fixed length lines, otherwise you will be best off reading in one file and write it out to another file.

    Comment


    • #3


      Continuing with this ...do you have an example of copying lines from one file to a temp location and then back? Can multiple files be open at once (one for reading, one appending) correctly? Been trying for a bit to code this and keep dropping beginning lines or not writing anything.

      Comment


      • #4


        I don't have an example, try the CONTROL.4dg sample in the FAT16 File project and make a few changes. You can certaingly have more than one file open at a time.

        Comment


        • #5


          Thanks for the help. Have one last question on this subject I believe...

          Currently have an array of characters that I would like to append ".txt" to and then pass that as the filename for file_Open. Been playing around with this and can't quite get it working correctly. Searched the forums and found an old thread about passing filenames to file functions having a bug. Has this been corrected since?

          Comment


          • #6


            The 4DGL code posted in my Screen Dump thread has the very code you are looking for.

            Steve

            Comment


            • #7


              heh ...I actually just came back to delete the message since I got it working now. I will check out your thread as well. Thanks!

              Comment

              Working...
              X