Conditional structures: Difference between revisions
Content deleted Content added
PatGarrett (talk | contribs) →if-then-else: remove extra ; |
m →{{header|REXX}}: added comments, elided duplicate blank lines, changed indentations. |
||
Line 3,518:
=={{header|REXX}}==
===IF--THEN, IF--THEN--ELSE===
<lang rexx>if y then
if t**2>u then x=y /*simple IF with THEN & ELSE. */
else x=-y▼
if t**2>u then
else x=-y /*simple ELSE. */
z=abs(z)▼
say 'z='z▼
end▼
else do; z=0; say 'failed.'; end /*ELSE DO group.*/▼
if x>y & c*d<sqrt(pz) |, /*this statement is continued [,]*/
▲ else x=-y
else nop /*NOP pairs up IF*/
else if z<0 then z=-y /*alignment helps*/</lang>▼
▲ z=abs(z)
▲ say 'z='z
▲ end
▲ else do; z=0; say 'failed.'; end
▲ substr(abc,4,1)=='@' then if z=0 then call punt
▲ else nop
▲ else if z<0 then z=-y</lang>
===SELECT--WHEN===
<lang rexx> /*the WHEN conditional operators are the same as
/*the IF conditional operators.
y=sqrt(z)
z=u**2
end
/*if control reaches
/*
select
when a=='angel' then many='host'
when a=='ass' | a=='donkey' then many='pace'
when a=='crocodile' then many='bask'
when a=='crow' then many='murder'
when a=='lark' then many='ascension'
when a=='quail' then many='bevy'
when a=='wolf' then many='pack'
otherwise many='?'
end /*2nd select*/ /* [↑] uses OTHERWISE as a catch-all.*/</lang>
===SELECT--WHEN/OTHERWISE===
Line 3,567 ⟶ 3,574:
otherwise say
say '*** error! ***'
say g "isn't one of the known thingys."
say
exit 13
|