Program REXX
Posted:
Fri 04 Dec 2009, 22:58
by celsofigueiredo
Dear.
I have to do a REXX program to calculate how many days left until the next anniversary of the mainframe (April 7, 1964). When you run the program in REXX, it should show the current date and ask the User that between the number of days per week to be considered useful (eg if I take note that Saturday and Sunday are not working days, would come with 5 . If you consider Sunday as not only useful, would come with 6). Display an error message if the number of working days is less than 1 or greater than 7. After the performance, display the total number of days missing, according to the number of days you took a week. I do not have much knowledge in REXX, but if you can help, I thank you.
Re: Program REXX
Posted:
Sat 05 Dec 2009, 10:54
by prino
Please ask such non-Dezhi specific questions in one of the
four mainframe forums mentioned in the
Mainframe FAQ forum, and supply
them with the code. You are much more likely to get a reply there than here.
Re: Program REXX
Posted:
Mon 07 Dec 2009, 17:48
by Rakesh kotha
Below code may help you!!
- Code: Select all
/*REXX*/
current_date = DATE(s)
say 'current date is: ;'date()
say 'number of days per week to be considered'
pull working_days
if working_days > 7 | working_days < 0 | working_days = '' then
do
say 'please enter value between 0 and 7'
exit
end
current_month = substr(current_date,5,2)
current_year = substr(current_date,1,4)
if current_month <= 4 then /* here 4 represets April month */
do
base_day2 = date('b','7 Apr 'current_year'')
base_day1 = date('b')
days_differance = base_day2 - base_day1
say 'total days remaining for birth day: ' days_differance
working_days_differance = days_differance/7*working_days
say 'working days remaining for birth day: ',
format(working_days_differance,3,0)
end
else
do
current_year = current_year + 1
base_day2 = date('b','7 Apr 'current_year'')
base_day1 = date('b')
days_differance = base_day2 - base_day1
say 'total days remaining for birth day: ' days_differance
working_days_differance = days_differance/7*working_days
say 'working days remaining for birth day: ',
format(working_days_differance,3,0)
end
Re: Program REXX
Posted:
Mon 07 Dec 2009, 21:06
by prino
"Give a Man a Fish, Feed Him For a Day. Teach a Man to Fish, Feed Him For a Lifetime" - Lao Tzu
Do not post complete solutions, help people find the solution themselves, don't show off!
Robert
Re: Program REXX
Posted:
Tue 08 Dec 2009, 23:44
by celsofigueiredo
Dear.
I changed a little more this REXX code, but still with errors in logic, is to improve more?
----------------------------------
- Code: Select all
/*REXX*/
/*trace i*/
current_date = DATE(s)
say 'A data de hoje eh: 'date()
do while working_days > 7 | working_days < 1
say 'numero de dias uteis a ser considerado (1 a 7): '
pull working_days
if working_days < 1 | working_days > 7 then
say 'Dias uteis tem que ser maior que 1 e menor que 7'
end
say 'Irao ser considerados 'working_days' dias uteis'
current_month = substr(current_date,5,2)
current_year = substr(current_date,1,4)
if current_month <= 4 then /* here 4 represets April month */
do
base_day2 = date('b','7 Apr 'current_year'')
base_day1 = date('b')
days_differance = base_day2 - base_day1
say 'Total de dias restantes para o dia de nascimento: ',
days_differance
working_days_differance = days_differance/7*working_days
say 'dias Ășteis restantes para os dias de nascimento: ',
format(working_days_differance,3,0)
end
else
do
current_year = current_year + 1
base_day2 = date('b','7 Apr 'current_year'')
base_day1 = date('b')
days_differance = base_day2 - base_day1
say 'Total de dias restantes para o dia de nascimento: ',
days_differance
working_days_differance = days_differance/7*working_days
say 'dias Ășteis restantes para os dias de nascimento: ',
format(working_days_differance,3,0)
end