On Thu, 23 Oct 2008 04:39:38 +0100, CM Poncelet wrote:

>Try:
>
>SAY 'Enter year'
>PULL YEAR
>DO WHILE \DATATYPE(YEAR,'N')
>  SAY 'Invalid date 'YEAR':' enter year, using only numeric digits'
>  PULL YEAR
>  END
>SAY 'Year is 'YEAR /* this line is just to verify ... */
>
I loathe the top-and-bottom input style.  The need for it is
a symptom of a deficiency of control structures in the language.
Would you code assembler this way?  What could be done with
SPM?

Better:

SAY 'Enter year'
DO InputYear=1
  PULL YEAR
  IF DATATYPE(YEAR,'N') THEN LEAVE InputYear
  SAY 'Invalid date 'YEAR':' enter year, using only numeric digits'
  END InputYear
SAY 'Year is 'YEAR /* this line is just to verify ... */

Best to code a function to put the expression in the
loop control:

SAY 'Enter year'
DO InputYear=1 WHILE \GETYEAR()
  SAY 'Invalid date 'YEAR':' enter year, using only numeric digits'
  END InputYear
SAY 'Year is 'YEAR /* this line is just to verify ... */
...
GETYEAR PROCEDURE
  PULL YEAR
  RETURN  DATATYPE(YEAR,'N')

Better languages allow a compound in the control expression
(not Rexx):

DO InputYear=1 WHILE (PULL YEAR; DATATYPE(YEAR,'N'))
    ...

-- gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to