• File.readln() not returning string occasionally

    From Nightfox@VERT/DIGDIST to All on Sunday, August 16, 2009 20:42:53
    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?

    Nightfox




    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com
  • From Digital Man@VERT to Nightfox on Monday, August 17, 2009 00:44:26
    Re: File.readln() not returning string occasionally
    By: Nightfox to All on Sun Aug 16 2009 08:42 pm

    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.

    digital man

    Snapple "Real Fact" #8:
    A bee has 5 eyes.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Deuce@VERT/SYNCNIX to Digital Man on Monday, August 17, 2009 09:59:25
    Re: File.readln() not returning string occasionally
    By: Digital Man to Nightfox on Mon Aug 17 2009 12:44 am

    File.readln() returns undefined when end of file is reached.

    If it's a typeOf object, it's most likely returning null. IIRC, typeOf(undefined) isn't "object".

    ---
    Synchronet - Jump on the Web 0.2 bandwagon!

    ---
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Nightfox@VERT/DIGDIST to Digital Man on Monday, August 17, 2009 11:47:01
    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)).

    Nightfox

    ---
    þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.com
  • From Digital Man@VERT to Nightfox on Monday, August 17, 2009 13:54:57
    Re: File.readln() not returning string occasionally
    By: Nightfox to Digital Man on Mon Aug 17 2009 11:47 am

    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)).

    That might depend on the file being read.

    digital man

    Snapple "Real Fact" #172:
    The eye makes movements 50 times every second.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net