• file operations.

    From douglas.mcallaster@gmail.com@21:1/5 to All on Sun Mar 8 09:44:25 2020
    Folks,

    I am trying to learn file operations.
    Using jobs from Don Lancaster's guru lair.

    His readline job works; but his read-one-char job fails.

    Can anyone fix and post a working read-one-char job?

    Thx, Doug

    %---readline job works
    % omits any line (ie last) which HAS CRLF
    % ie need an empty line as last one
    /strx 256 string def
    (donin.txt) (r) file /myworkfile exch def
    {myworkfile strx readline
    { = }
    {myworkfile closefile exit} ifelse
    } loop
    quit

    %---read-one-char job-fails
    /strx (X) def
    (donin.txt) (r) file /myworkfile exch def
    {myworkfile read { strx exch 0 exch put
    = }
    {myworkfile closefile exit} ifelse
    } loop
    quit

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From news@zzo38computer.org.invalid@21:1/5 to douglas.mcallaster@gmail.com on Sun Mar 8 14:39:34 2020
    douglas.mcallaster@gmail.com wrote:

    Folks,

    Can anyone fix and post a working read-one-char job?

    %---read-one-char job-fails
    /strx (X) def
    (donin.txt) (r) file /myworkfile exch def
    {myworkfile read { strx exch 0 exch put
    = }
    {myworkfile closefile exit} ifelse
    } loop
    quit

    The problem is that the "=" should be "strx ="; that is why it
    doesn't work. If you make that change, then it will work. The
    original code does not have any input for the = so the operand stack
    is empty by that time, and it won't work.

    --
    Note: I am not always able to read/post messages during Monday-Friday.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)