Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine if fgets ends with CR or length of 8192
Message
From
27/11/2011 21:19:28
 
 
To
27/11/2011 03:00:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01529844
Message ID:
01529898
Views:
34
>>>>I am parsing Medical HL7 format records. I'm using fgets() to read them as a flat file. Some of the record formats have interpretations of the data that exceeds the 8192 maximum length of the fgets. When I get the data if the length is less than 8192 then it is obvious the length is what it is. If the length of the data is 8192 how can I tell if the fgets completed because of a CR or there is more data for that record?
>>>
>>>You cannot tell a difference from FGETS() but you can use FSEEK(nFileHandle,0) to track a file pointer in a file. The difference between previous an current value should allow you to determine both cases.
>>
>>
>>I'm not understanding. I can use len() to find if I got 8192. If that is the len how can I determine of the next character is part of the record just read or the start of the next record??
>
>Forget 8192.
>
>If VFP uses the CR, then FSEEK(fhandle, 0.1) will be 1 or more characters forward LEN (fgets ()).
>
>Then
>
>* loop
>fPosition=FSEEK(fhandle,0,1) 
>cFgets=FGETS(fhandle,8192)
>if FSEEK(fhandle,0,1) =m.fPosition+LEN(m.cFgets)
>   * line continue
>else
> *line end

Fabio,

Thanks for your routine.  This works great.  I love simple answers.

Alan
>endi
>* loop
>
Previous
Reply
Map
View

Click here to load this message in the networking platform