Answer to question 24

A parse pull is not the best choice as it may get lines from the program stack.  A parse (upper) external, or to be more portable with other REXX SAA Level 2 systems, a parse (upper) linein is a better choice as it looks only at the terminal input buffer.

Next piece of code is kind of a general way to ask a question to the user, and includes logic to allow for a null entry :

  say 'Enter Yes or press ENTER to continue, anything else to terminate'
  parse upper linein 1 answer 2
  if ¬abbrev('YES',answer) then exit

while this one loops until a valid answer is replied by the user :

  answer=''
  do while answer=''
     say 'Enter the number of elements or Quit to terminate'
     parse upper linein answer .
     if abbrev('QUIT',answer,1) then exit
     if ¬datatype(answer,'N') then do
        say 'Your answer 'answer' is not numeric'
        answer=''
     end
  end

You might cut-and-paste these for re-use in your procedures.

Use the backward navigation button of your browser to return to the lesson.