>>Hello all
>>
>>I have a text file with 7 lines and 8th line is blank when i issue
>>lcFile=Filetostr(cfile)
>>numLines=Alines(aTextArray,lcFile)
>>
>>i get numlines as 8 how to get it to 7
>>
>>txs
>
>Alines counts CRLF or LF and trim() doesn't trim CRLF chars. Below code assumes linecount is not over array limit and returns result eliminating blank lines at top, between lines or at end.
>
>
>lnLines = alines(arrLines,FileToStr('myFile.txt'))
>TotLines = lnLines
>for ix=1 to lnLines
> if trim(arrLines[ix])==''
> TotLines = TotLines - 1
> endif
>endfor
>? TotLines
Cetin
In another branch of this thread you give a sample that looks like your intention is to process an SDF file. If so you don't even need to count nonempty lines and directly do it in your 'append from..' code. Assuming one of your fields should never be empty (a key maybe) and named myField you could do this :
append from myText.txt type SDF for !empty(myField)
Cetin