XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Counting the number of lines

01-26-2009, 05: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.


01-26-2009, 05:52 PM
Its ok I have just realised where I have gone wrong on that.

02-01-2009, 11:51 AM
Here's a shorter and probably faster method using .NET:
((dotNetClass "System.IO.File").ReadAllLines textInstructionFile).count

CGTalk Moderation
02-01-2009, 11:51 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.