Greetings,

I'm using 'Mozart Compiler 1.3.1 (20040617) playing Oz 3' in a Win2K
environment.

I'm using the following approach to read in a redirected text file from
stdin:

    ...{New TextFile init(name:stdin)}...

    ...
    fun {LoadData FILE DATATBL}
        case {FILE getS($)} of false then
            DATATBL
        elseof DATUM then
            {LoadData FILE {Append DATATBL [{String.toFloat DATUM}]}}
        end
    end
    ...

I've used this read / load approach before with no problem. However, in this
case the attempted conversion to float is failing. A {System.show DATUM}
call reveals that the Carriage Return [CR] code is not being removed as part
of the read step; this is appearing:

    [49 13]

rather than this:

    [49]

I can certainly work around this behaviour by doing something like this:

    ...{String.toFloat {List.take DATUM ({Length DATUM} - 1)}}...

However, I would have thought that since the Line Feed [LF] code is being
removed as part of the read step, then so should the CR ?

According to the Oz documentation [Section 19.2] this is the case - CRLF is
converted to LF [provided the file is opened in 'text' mode], then, the
implied behaviour is that LF is stripped on reading. To ensure the
redirected file was so opened I altered the code to:

    ...{New TextFile init(name:stdin flags:[read text])}...

only to have the behaviour described earlier repeated.

My question then is: Is this a 'known problem', or have I missed something
in appropriately configuring the code ?

Any help appreciated.

Cheers,

Anthony Borla


_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to