Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Rexx Programming/How to Rexx/if

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

The if conditional construct allows a /statement/ or /block/ of code to be conditionally executed based on the result of a boolean expression. The branch within the condition, only gets executed if the expression evaluates to a true value. The if condition its simplest form is: if CONDITION then STATEMENT For example: if guess = 6 then say "Wow! That was a lucky guess." There is no endif cocomponent Note that rexx programming language syntax does not utilize endif as a syntactical cocomponent. The endif placed in a comment in example below are for cosmetic purposes only for aiding indentation. These comments are ignored by the rexx interpreter. if guess = 6 then say "Wow! That was a lucky guess." else say "Sorry! That was not the right number." /* endif */ Using the do construct to conditionally execute a branch containing more than one statement In order to conditionally execute more than one statement within a conditional branch, it is necessary to enclose the statements within a do and end block: if guess = 6 then do say "Wow! That was a lucky guess." /* Multiple statements in a do block */ prize = 30000 end Nested conditional constructs It is possible to created nested if structures: if age > 79 then say "Wow! You are so old that you are almost antique!" else if age >=65 then say "You are a pensioner" else if age > 21 then say "You have the key to the door" else say "You are just a youngster" /* endif */ /* endif */ /* endif */