Here are some solutions to selected REXX exercises submitted by OS/2 SIG members. They were submitted in the spirit of sharing. If you have a better solution, let us hear from you. All ideas are welcome.
/* Philly OS/2 rexx exercise */ say "rexx exercise 1" sum = 0 do i = 1 to 50 say "number" i sum = sum + i end say "sum" sum
/* Philly OS/2 rexx exercise */ say "rexx exercise 2" sum = 0 do i = 1 to 51 by 2 say "number" i sum = sum + i end say "sum" sum
/* Philly OS/2 rexx exercise */ SAY "rexx exercise 3" SAY A DO A = 10 TO 3 BY -2 SAY "Top of Loop" SAY A END SAY A
/* Philly OS/2 rexx exercise */
say "rexx exercise 4"
SAY A
DO A = 1 TO 1 while B < 5
SAY "Top of Loop"
Say "A=" A "B=" B
B = A + 2
SAY "B=" B
END
SAY "END A=" A "; B=" B
/* Philly OS/2 rexx exercise */
say "rexx exercise 14"
/* outer loop variables */
outerLoopStart = 1
outerLoopEnd = 49
outerLoopIncr = 5
/* inner loop variables */
innerLoopStart = 0
innerLoopEnd = 4
innerLoopIncr = 1
/* lines per page */
linesPerPage = 3
currLine = 0
/* numeric format */
len = 5
decimals = 2
/* output string */
output = ""
/* loop */
row = 1
do i = outerLoopStart to outerLoopEnd by outerLoopIncr
output = "row " || row || ":"
do j = ( i + innerLoopStart ) to ( i + innerLoopEnd ) by innerLoopIncr
output = output || " " || format( j, len, decimals )
end
say output
currLine = currLine + 1
if ( currLine = linesPerPage ) then do
say "hit [ENTER] to continue"
parse linein
currLine = 0
end
row = row + 1
end
/* completion */
say "program completed!"
/* Philly OS/2 rexx exercise */ say "rexx exercise 15" /* outer loop variables */ outerLoopStart = 1 outerLoopEnd = 50 outerLoopIncr = 5 /* inner loop variables */ innerLoopStart = 0 innerLoopEnd = 4 innerLoopIncr = 1 /* lines per page */ linesPerPage = 3 currLine = 0 /* numeric format */ len = 5 decimals = 2 /* output string */ output = "" /* loop */ row = 1 do i = outerLoopStart to outerLoopEnd by outerLoopIncr output = "row " || row || ":" do j = ( i + innerLoopStart ) to ( i + innerLoopEnd ) by innerLoopIncr output = output || " " || format( j, len, decimals ) end say output currLine = currLine + 1 if ( currLine = linesPerPage ) then do say "hit [ENTER] to continue" parse linein currLine = 0 end row = row + 1 end /* completion */ say "program completed!"
Rexx Group Charter
Lesson 1 | Lesson 2 | Lesson 3 | Lesson 4
Exercises 1 | Exercises 2 | Exercises 3
Answers to exercises
Exercises 1
Example code
Stock Market | Stock Market_a
About these pages | Page building by: | Content updated 07-09-2005 07:43am |