Hi see my rexx exec

/* rexx  by Claudio Marcio */
Say 'Enter with the year',
pull year
do while \datatype(year,'N')
 SAY 'Invalid Date!!... enter year, using only numeric digits''
 pull year
end
do until answer \= "S"
 dec25 = date("B",year"1225","S")//7
 select
    when dec25 = 0 then day = "Segunda-feira"
    when dec25 = 1 then day = "Terca-feira"
    when dec25 = 2 then day = "Quarta-feira"
    when dec25 = 3 then day = "Quinta-feira"
    when dec25 = 4 then day = "Sexta-feira"
    when dec25 = 5 then day = "Sabado"
   when dec25 = 6 then day = "Domingo"
end
if year < right(date(),4) then
   say 'In 'year', the Christmas was 'day
   else
   say 'In 'year', the Christmas will be 'day

say 'Want to learn some more years? (s/n)'
pull answer
if answer = "S" then
     say 'Enter with another year!'
pull year --------------------------------------------------- > HERE TO UP it´s ok
     do while \datatype(year,'N')
       SAY 'Invalid Date!!... enter year, using only numeric digits''  ,
       pull year
     end
end
if answer = "N" then ------------------------------> not be enter to if when type answer equal the "N"??? do the program returns to the message of while command and say 'Invalid answer BYE! BYE!' when type the year( ex. 1970), he cancel ??? why??
      leave
    end
end more a question... how to verify the number of digits of the year?? end ex. If digits of thhe year less than 4 exit say 'Invalid Date!!... Invalid number of the digits'



regards


**************************** Bottom of Data *************************

if answer = "N" then
----- Original Message ----- From: "Paul Gilmartin" <[EMAIL PROTECTED]>
Newsgroups: bit.listserv.ibm-main
To: <IBM-MAIN@BAMA.UA.EDU>
Sent: Thursday, October 23, 2008 12:10 PM
Subject: Re: Loop in REXX


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


----------------------------------------------------------------------
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