![[Toc]](../../toc.gif)
![[Index]](/idx.gif)
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
other).
---------- * ----------
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
do
/* 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 || '"'
EndProgram:
exit
/* ------------------------------------------------------------------ */
/* error handler */
Halt:
say
say '*** CTRL-C pressed ***'
say ' Note that the next calls of LineIn() will return immediately'
say ' without reading any data!'
say '*** -------------- ***'
say
return
---------- * ----------
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
<LINEIN
Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs