Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Text file returning incorrect no.of.lines
Message
From
13/06/2002 06:39:00
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/06/2002 15:08:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00667588
Message ID:
00667821
Views:
19
This message has been marked as the solution to the initial question of the thread.
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform