Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I =fgets(lnHandle,9999) ?
Message
From
28/09/1998 19:32:58
 
 
To
28/09/1998 18:57:58
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00141670
Message ID:
00141686
Views:
20
>I want to read in a whole line at a time (to the charriage return) from a text file, but the lines are always longer than 256 characters and I don't know how long they are and they vary in length in the same file.
>
>How can I read a complete variable length line from a text file when the line is longer that 256 characters?
>
>TIA

You do it exactly the way you stated in your topic:

cDataVal = FGETS(nFileHandle,nBytes)

From the FGETS help:
nBytes Specifies the number of bytes FGETS( ) returns. FGETS( ) returns nBytes bytes unless a carriage return is encountered first. FGETS( ) returns data between the starting file-pointer position and the carriage return if a carriage return is encountered within nBytes bytes.

If you omit nBytes, FGETS( ) returns a maximum of 254 bytes by default.


A variable can be bigger than 254 long. A field in a table can not.

So if you wanted to read upto 1000 bytes, you would:

cDataVal = FGETS(nFH,1000)

The variable cDataVal would contain the string up to the first CR or 1000 bytes, whichever comes first. Just keep looping through the file until done.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform