Menu

#487 Error in example of CharIn() return

v3.9.1
open
nobody
7
2016-11-07
2016-11-07
Aviatrexx
No

On p. 153:

Suppose a text file contains the following three lines (ASCII character set is assumed):

    first
    second
    third

and you first read it line-wise and then character-wise. Assume the following program:

    file = 'DATAFILE'
    foo = ''
    do i=1 while chars(file)>0
    foo = foo || c2x(charin(file))' '
    end
    say foo

When the file is read line-wise, the output is identical on all machines, i.e. the three lines shown above. However, the character-wise reading will be dependent on your operating system and its file system, thus, the output might e.g. be any of:

    66 69 72 73 74 73 65 6F 63 6E 64 74 68 69 72 64 66 69 72 73 74 0A
                                                                                                            ^^^^^^^^^^^^^^
                                                                                                             not returned

Discussion


Log in to post a comment.