>Hi Everyone:
> I want to count the number of fields there are in a delimited text file. Here is my code.
>
>****code******
>FSEEK(lnHandle, 0,0) ** seek record
> DO WHILE !FEOF(lnHandle)
> lsBuf = FGETS(lnHandle, 1024)
> && lsBuf contains a record. I.E. lsbuf = '|F845|,2569,69899,0,0,25989,1
> What I need is to get the number of fields in this record. In this case
> there are 7 fields in the record.
> EndDo
>Thanks
>MA
Off the top of my head I'd do something like this. Process your text string in a for loop and count the number of times the separator character is found.
***********************************
LOCAL iloop, iresult, iret
STORE 0 TO iloop, iresult, iret
FOR icnt = 1 TO 9999999
iret = ATC(",",lsbuf,icnt)
IF iret > 0
iresult = iresult + 1
ELSE
EXIT
EndIF
ENDFOR
MEssageBox([ Number of Fields is ]+ALLTRIM(STR(iresult,20,0))+[. ]
***********************************
Something like that.
Fred Lauckner
You know, it works on my computer. I don't know what your problem is.
.Net aint so bad.