Product Site

Chapter 2. Keyword Instructions

2.1. ADDRESS
2.2. ARG
2.3. CALL
2.4. DO
2.5. DROP
2.6. EXIT
2.7. EXPOSE
2.8. FORWARD
2.9. GUARD
2.10. IF
2.11. INTERPRET
2.12. ITERATE
2.13. LEAVE
2.14. LOOP
2.15. NOP
2.16. NUMERIC
2.17. OPTIONS
2.18. PARSE
2.19. PROCEDURE
2.20. PULL
2.21. PUSH
2.22. QUEUE
2.23. RAISE
2.24. REPLY
2.25. RETURN
2.26. SAY
2.27. SELECT
2.28. SIGNAL
2.29. TRACE
2.29.1. Trace Alphabetic Character (Word) Options
2.29.2. Prefix Option
2.29.3. Numeric Options
2.29.4. Tracing Tips
2.29.5. The Format of Trace Output
2.30. USE
2.30.1. USE ARG, USE STRICT ARG
2.30.2. USE LOCAL

A keyword instruction is one or more clauses, the first of which starts with a keyword that identifies the instruction. Some keyword instructions affect the flow of control, while others provide services to the programmer. Some keyword instructions, like DO, can include nested instructions.

In the syntax diagrams on the following pages, symbols (words) in capitals denote keywords or subkeywords. Other words, such as expression, denote a collection of tokens as defined previously. Note, however, that the keywords and subkeywords are not case-dependent. The symbols if, If, and iF all have the same effect. A clause requires a semicolon (;) as a terminating delimiter unless the end of a line implies it.

A keyword instruction is recognized only if its keyword is the first token in a clause, the second token does not start with an equal (=) character (implying an assignment) or a colon (implying a label), and the whole instruction does not have the form of a message instruction. The keywords ELSE, END, OTHERWISE, THEN, and WHEN are treated in the same way. Note that any clause that starts with a keyword defined by Rexx cannot be a command. Therefore,
arg(fred) rest

is an ARG keyword instruction, not a command that starts with a call to the ARG built-in function. A syntax error results if the keywords are not in their correct positions in a DO, IF, or SELECT instruction. The keyword THEN is also recognized in the body of an IF or WHEN clause. In other contexts, keywords are not reserved and can be used as labels or as the names of variables (though this is generally not recommended).

Subkeywords are reserved within the clauses of individual instructions. For example, the symbols VALUE and WITH are subkeywords in the ADDRESS and PARSE instructions, respectively. For details, see Chapter 16, Reserved Keywords.

Whitespace characters (blanks or horizontal tabs) adjacent to keywords separate the keyword from the subsequent token. One or more whitespace characters following VALUE are required to separate the expression from the subkeyword in the example following:
 ADDRESS VALUE expression

However, no whitespace character is required after the VALUE subkeyword in the following example, although it would improve readability:
ADDRESS VALUE"ENVIR"||number