REXX Tips & Tricks, Version 2.80

Inf-HTML [About][Toc][Index] 0.9b (c) 1995 Peter Childs

The functions LINEIN() and PULL()

If you've activated the trap of the NOTREADY condition, you got a NOTREADY 
condition in the following case: 
  Use the function  <LINEIN to read from STDIN 
  Call the program with a redirection for STDIN 
  <LINEIN tries to read the end of the file 
You cannot prevent this error by using <LINES. 
If you're using <PULL to read from STDIN you won't get an error. Instead 
<PULL won't detect the end of the file and will read empty lines forever. 
This behavior is independent of the last byte in the input file (CTRL-Z or 
---------- * ----------

There's a bug in the CTRL-C handling of the <LINEIN function: 

/* ------------------------------------------------------------------ */
/* sample code to show a bug in the CTRL-C handling of Classic REXX   */
/*                                                                    */

  parse version interpreterType .
  if interpreterType = 'OBJREXX' then
                    /* Object REXX running                            */
    say 'This bug will only occur in Classic REXX'
    exit 0
  end /* if */

                    /* install an error handler for CTRL-C/BREAK      */
  call on halt

  call LineOut , "Enter a string (press CTRl-C to see the bug):"
  UserResponse = lineIn();

  say 'UserResponse is "' || userResponse || '"'

/* -------- uncomment the next statement for a workaround  ---------- */
/*                                                                    */
/*                     close STDIN to avoid a bug in the CTRL-C       */
/*                     handling                                       */
/*                     Note that the next LineIn call reopens STDIN.  */
/*  call stream 'STDIN', 'c', 'close'                                 */
/* ------------------------------------------------------------------ */

  say 'Now executing the statement: userResponse1 = lineIn()'
  UserResponse1 = lineIn()

  say 'UserResponse1 is "' || userResponse1 || '"'

  say 'Now executing the statement: userResponse2 = lineIn()'
  UserResponse2 = lineIn()

  say 'UserResponse2 is "' || userResponse2 || '"'



/* ------------------------------------------------------------------ */
/* error handler                                                      */


  say '*** CTRL-C pressed ***'
  say '    Note that the next calls of LineIn() will return immediately'
  say '    without reading any data!'
  say '*** -------------- ***'

---------- * ----------

In Classic REXXX, pressing CTRL-C while the function <LINEIN is active 
immediately activates the handler for the HALT signal; pressing CTRL-C 
while the function <PULL is active, activates the handler for the HALT 
signal after entering ENTER. 
In Object REXX the behaviour for <PULL is similar to the behaviour for 

Inf-HTML End Run - Successful