Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field Count
Message
From
14/12/2000 13:01:00
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00453472
Message ID:
00453491
Views:
17
Mahmmod:

> I want to count the number of fields there are in a delimited text file.


1. Use FGETS to read a line (first occurence of a Chr(13).
2. Parse your line and strip everything between double-quotes (you don't
want to count the commas included in these fields)

lcLine = < your line >
lcStripped =
lnComma = 0
For x = 1 To len(lcLine)
cChar = Substr(lcLine, x, 1)
If cChar = '""' Then
If lnComma = 0
lnComma = 1 && the start to read a character field
Else
lnComma = 0 && the end of a character field.
EndIf
Else
If lnComma = 0
*-- Note that you do nothing if lnComma = 1 because you
*-- are reading a character field.
lcStripped = lcStripped + cChar
EndIf
EndIf
EndFor

3. The number of fields is:
OCCURS(",", lcStripped) + 1

Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform