| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Flow Control In Rexx |
Excerpted from message dated 04-10-95, Andrew Clegg to All:
AC>Does REXX have an equivalent of C's switch/case or Pascal's case
>staements?
Hi Andrew--
The equivalent is SELECT, only it is better done. Here is a small
example from Mike Cowlishaw's book: "The REXX Language: A Practical
Approach to Programming, 2nd Edition" (ISBN 0-13-780651-5).
_______example starts here
Testfile myfile
select
when rc=0 then do
Erase myfile
say 'File' myfile 'existed, now erased'
end
when rc=28 | rc=36 then say myfile 'does not exist'
otherwise
say 'Unexpected recturn code "'rc'" from TESTFILE'
exit rc
end /* Select */
_______example ends
Although not shown in this example, each "when" clause in the
"select" construct can refer to a different variable if need be! Notice
there is no such nonsense as a "break" for each "when" to prevent
automatic passage to the next one. REXX is the programmer-friendly
language!
--Murray
___
* MR/2 2.21 #120 * One printed manual is worth a thousand INF files
---
* Origin: 2" x 4" bbs - a basic board - (914) 271-9407 (1:2625/108)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 2625/108 1 261/1023 270/101 105/103 42 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.