>
>FGETS can be used to read ASCII files line by line.
>Parse the line backwards from the end of the line looking for spaces, the first 5 spaces will give the last 5 fields, the remainder from the start of the line will be the first field.
>
>I've sketched out the rough idea below - it's probably got a few bugs in, so check it out carefully.
>
>fh = FOPEN( "xxx" )
>DO WHILE NOT FEOF( fh )
> raw = FGETS( fh )
>
> endpos = LEN( raw )
> FOR startpos = endpos TO 1 STEP -1
> IF SUBSTR( raw, startpos, 1 ) = " "
> EXIT
> ENDIF
> ENDFOR
> field6 = SUBSTR( raw, startpos, endpos-startpos+1 )
> endpos = startpos
>* repeat above for loop for each field
>*
>ENDDO
>FCLOSE( fh )
>
>hth
>Paul
RAT(' ',lcData) would be quicker than a for loop. Returns the position of the character in one call.
DO WHILE AT(' ',lcData)
lcLineData=SUBSTR(lcData,RAT(' ',lcData)+1)
lcData=LEFT(lcData,RAT(' ',lcData)-1)
ENDDO
I don't think this will work in this case because you can't be certain that the data on one line doesn't include a space.
I certainly can't think of any solution. I've done this sort of thing many, many times but usually find some kind of pattern or separator.
Michiel: try using a hex editor on the text file - you may find a non-space character where you thought the space was. Make sure you use the original file (reload it if necessary) as some utilities put spaces where you don't want them. I believe there is a hexedit program with VFP5 (in tools, I think).