Punctuation
This section first lists the symbols that are used as separators and the symbols that are used as operators. Then it describes how to use the symbols &+ as line continuation characters. Finally, it explains how ampersands, apostrophes, exclamation points, and dollar signs are used in macros.
Separators
The following characters are used as separators in macros:
Operators
The following characters are used as operators in macros:
** (exponentiation)
+ (positive), - (negative), ^ (not)
* (multiplication), / (division)
+ (addition), - (subtraction)
|| (concatenation)
<, <=, =, ^=, >=, > (relations)
& (and)
| (or)
See the description of the (calc) command function in Appendix C for more information about operators and their use in expressions.
Line Continuation Characters
You can continue a line in a macro onto a second or subsequent line by adding the characters &+ before you press to continue the line. To include a line in a macro that exceeds the maximum line length for a file, you must use line continuation characters. In addition, by presenting a long line as separate lines in this way, you can make the long line easier to read and understand.
The macro processor treats lines joined by line continuation characters as if they were one line. Any leading blanks on the second or subsequent lines are ignored.
Ampersands
In some circumstances, the ampersand character (&) requires special treatment. A single ampersand can be interpreted by the macro processor as any of the following:
- a macro statement indicator
- a comment line indicator
- a parameter delimiter (parameters are described later in this chapter)
- the "and" logical operator
If you want to include an ampersand in a macro but you do not want the command processor to interpret it as an indicator, a delimiter, or a logical operator, you must use two ampersands where you want the single ampersand to appear.
For example, suppose the current value of the macro variable &source& is make_reports.cobol. (Macro variables are described later in this section.) Now consider this command macro line:
&display_line The variable &source& is about to be used.
This line is displayed:
The variable make_reports.cobol is about to be used.
In contrast, consider the following command macro line:
&display_line The variable &&source&& is about to be used.
In this case, the following line is displayed:
The variable &source& is about to be used.
Apostrophes
There are two circumstances that require apostrophes in macros:
- To include an apostrophe in a character string within a macro, enclose the entire string in apostrophes, and use two apostrophes where you want the single apostrophe to appear within the string. For example:
!display_line 'Enter your employer''s address.'
- Normally, a command function inside a quoted string is not evaluated and replaced. If you want such a command function to be evaluated and replaced, enclose the command function (including its parentheses) in apostrophes. For example:
!display_line 'Your current directory is '(current_dir)'.'
Exclamation Points
An exclamation point (!) in a macro tells the operating system not to expand any abbreviations that occur between the exclamation point and the end of the line. It is a good practice to use exclamation points preceding every command and command line in a macro.
For a full explanation of the use of exclamation points and of the need to suppress abbreviations, see the section Abbreviations in Macros later in this chapter.
Dollar Signs
The dollar sign ($) can be used with macro variables in command macros. (Macro variables are described later in this section.)
To enclose the value of a variable in apostrophes when it is replaced, you can use a dollar sign as a prefix to the variable name. Using this prefix with a variable is similar to specifying the variable as the argument of the (quote) command function (see Appendix C), except that the dollar sign allows unbalanced quotation marks in the string, but (quote) does not.
For example, if the current value of the parameter &source& is make_reports.cobol, the macro statement &display_line &$source& displays the output 'make_reports.cobol'
|