Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fseek() and fgets()
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00124862
Message ID:
00124865
Views:
16
>Hello All,
>I have an app that needs to fopen an ascii file,
>fgets() pulls out the first string.
>I manipulate the data here and then;
>I need to overwrite the line with the new info.
>All this inside a DO while Not feof() loop;
>
>I am not using fputs() to write the line becuase various
>sources of these ascii files may have different carriage returns so I have determined before hand what the return is and store it in a variable. THis way I can =fwrite(maniupateed data + variable)
>
>My problem is I am not successfully moving down with the file
>pointer thus never gettting to FEOF().
>
>I know the length of each record and I also have a counter as I go down the file. SO, I could do an fseek() to the top of the fiel and then move down by string length * the counter.
>
>How do I do this?
>Thanks,
>Sandy

The more reliable way is to built string moving through the file:
DO WHILE NOT FEOF()
cString=cString+manipulate(fgets())+'neseccary carriage returns"
ENDDO
When this loop is over, you Fcreate() new file and Fwrite() this string there. The source file can be deleted afterward
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform