Chapter 6
Macro Expressions
Macro Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Defining Arithmetic and Logical Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Evaluating Arithmetic and Logical Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Operands and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
How the Macro Processor Evaluates Arithmetic Expressions . . . . . . . . . . . . . . . . . 76
Evaluating Numeric Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Evaluating Floating-Point Operands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
How the Macro Processor Evaluates Logical Expressions . . . . . . . . . . . . . . . . . . . . 78
Comparing Numeric Operands in Logical Expressions . . . . . . . . . . . . . . . . . . . . . . 78
Comparing Floating-Point or Missing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Comparing Character Operands in Logical Expressions . . . . . . . . . . . . . . . . . . . . . 79
Macro Expressions
There are three types of macro expressions: text, logical, and arithmetic. A text
expression is any combination of text, macro variables, macro functions, or macro calls.
Text expressions are resolved to generate text. Here are some examples of text
expressions:
&BEGIN
%GETLINE
&PREFIX.PART&SUFFIX
%UPCASE(&ANSWER)
Logical expressions and arithmetic expressions are sequences of operators and operands
forming sets of instructions that are evaluated to produce a result. An arithmetic
expression contains an arithmetic operator. A logical expression contains a logical
operator. The following table shows examples of simple arithmetic and logical
expressions:
Table 6.1 Arithmetic and Logical Expressions
Arithmetic Expressions Logical Expressions
1 + 2 &DAY = FRIDAY
73
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset