Hi all -
The Synchronet JavaScript docs say that File's readln() function returns a string. I've run into a situation where it seems to return something different occasionally. I was using readln() to read lines from a file,
and there were some blank lines at the end. When it gets to the last line, the thing returned by readln() seems to be of type "object" rather than "string" (I know this because I was using typeof() to test what was returned). Is it supposed to do that, or might it be a bug?
File.readln() returns undefined when end of file is reached.
File.readln() returns undefined when end of file is reached.
Re: File.readln() not returning string occasionally
By: Digital Man to Nightfox on Mon Aug 17 2009 00:44:26
File.readln() returns undefined when end of file is reached.
What's weird is that what I was seeing doesn't seem to be consistent.
There were times when I could read an entire text file without problems,
and then when reading one particular text file, the script exited with the error that my file line variable had no properties. With File.readln() returning undefined when the end of file is reached, wouldn't a script exit with that error every time if it doesn't check the type of what readln() returned?
I also had my file reading code in a loop that checked File's eof property (i.e., while (!inFile.eof)).
Sysop: | Chris Crash |
---|---|
Location: | Huntington Beach, CA. |
Users: | 579 |
Nodes: | 8 (0 / 8) |
Uptime: | 00:33:00 |
Calls: | 10,740 |
Files: | 5 |
Messages: | 444,492 |