Overview, Statements, Comparisons, Branches, Repetition
Basics
The Hello World program is a tradition that dates back to 1974.
Output:
Hello, my beloved worldBasics
Strings are delimited by apostrophes (') or by quotes (")
Example:
Becomes:
Basics
Basics
Variables allow storing, changing, and retrieving strings with the help of a discretionary name called an identifier
Output:
Hello, my beloved variable - changed again.Identifiers must begin with a letter, an exclamation mark, a question mark or an underline character, followed by one or more of these characters, digits, and dots.
Basics
The constant value is assigned to a variable, the value of which never gets changed in the entire program (after all, it is a constant!)
In ooRexx use the ::constant name value directive
Basics
Comments may be nested and are allowed to span multiple lines.
Output:
7Line comments: at the end of a statement, comments follow after two consecutive dashes:
Output:
7Basics
Statements consist of all characters up to and including the semi-colon (;)
There may an arbitrary number of statements on a line
If the semi-colon is missing, then the end of a statement is assumed by the end of a line
Output:
Hello, my dear worldBasics
Output:
Hello, my beloved world
Basics
Output:
Hello,
world
Basics
test_expression), 1Two values (constant, variable, results of function calls) can be compared with the following (Infix) operators (Result: 0=false or 1=true)
= |
equal |
<> \= |
unequal |
< |
smaller |
<= |
smaller than |
> |
greater |
>= |
greater than |
Negation of Boolean (0=false, 1=true) values
| \ | Negator |
Basics
test_expression), 2Boolean values can be combined
& |
"and" (true: if both arguments are true) |
| |
"or" (true: if either argument is true) |
&& |
"exclusive or" (true: if one argument is true and the other is false) |
Boolean combinations can be evaluated in a specific order if enclosed in parentheses:
0 & 1 | 1 |
Result: 1 (= true) |
(0 & 1) | 1 |
Result: 1 (= true) |
0 & (1 | 1) |
Result: 0 (= false) |
Basics
test_expression), 3a=1 |
|
b=2 |
|
x="Anton" |
|
y=" Anton " |
|
If a = 1 then ... |
Result: 1 (= true) |
If a = a then ... |
Result: 1 (= true) |
If a >= b then ... |
Result: 0 (= false) |
If x = y then ... |
Result: 1 (= true) |
If x == y then ... |
Result: 0 (= false) |
a <= b & (a = 1 | b > a) |
Result: 1 (= true) |
\(a <= b & (a = 1 | b > a)) |
Result: 0 (= false) |
\a |
Result: 0 (= false) |
Basics
IF test_expression=.true THEN statement;
IF test_expression=.true THEN statement; ELSE statement;
Basics
Basics
Basics
Using a variable to control the number of repetitions
Output:
Basics
Repetition using a loop variable ("i" in this example)
Output:
Basics
Repetition using a loop variable ("i" in this example)
Output:
Basics
Repetition using a control variable ("i" in this example)
Output:
Basics
Conditional repetition (evaluated at the beginning of the block)
Output:
Aua!
Oh! 2Basics
Conditional repetition (evaluated at the beginning of the block)
Output:
→ No output, because block is not executed!
Basics
Exit condition (evaluated at the end of the block)
Output:
Aua!
Oh! 3Basics
Basics
or:
or:
or:
WU
Prof. Mag. Dr. Rony G. Flatscher
Welthandelsplatz 1
1020 Wien/Vienna
Austria/Europe
www: www.wu.ac.at