Notifications
Clear all
[Closed] Counting the number of lines
Jan 26, 2009 5:40 pm
Hi Guys,
I am having a bit of a problem trying to determine how many lines are in a text file (textInstructionFile – already defined).
I am trying to use this code but if errors after it prints ‘2’ when it gets to the second line.
textInFile = openFile textInstructionFile
s=stringstream (readLine textInFile)
totalNumberOfFrames = 1
while not eof s do
(
totalNumberOfFrames = totalNumberOfFrames + 1
print totalNumberOfFrames
skipToNextLine s
)
Can anyone see where I am going wrong?
Thanks for any help.
Spencer
2 Replies
Jan 26, 2009 5:40 pm
Here’s a shorter and probably faster method using .NET:
((dotNetClass "System.IO.File").ReadAllLines textInstructionFile).count
Cheers,
Martijn