>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.