Perform Constants and Variables in Editor Macros

Variables let you associate data with a unique name. With Editor macros, you can display, compare, do arithmetic, or many other functions with the value stored in the variable name.

The first character of a variable name must be one of:

Other characters in the variable name can be any of the characters listed above, plus the digits 0 to 9.

You can assign a value to a variable. This value can be a constant value, the value of another variable, the result of an arithmetic or logical expression, or the result of a REXX function. String constants must be enclosed in single or double quotes. Numeric constants, names of other variables, and REXX function names do not require quotes.

In the examples below, the variable name appears to the left of the = sign, and the constant, expression, or function value being assigned to the variable appears to the right of the = sign.

   a = 10                  - a is assigned a value of 10 
   b = 10.5                - b is assigned a value of 10.5
   result1 = 1 + 1         - result1 is assigned a value of 1 + 1, or 2 
   result2 = result1 + 20  - result2 is assigned the result of the 
                              arithmetic expression result1 + 20,
                              where result1 is a numeric variable.
   his_name = "Adrian"     - his_name is assigned the character string Adrian 
   her_name = 'Sandra'     - her_name is assigned the character string Sandra 
   evens = 2 4 6 8         - evens is assigned a list of values 2 4 6 8 
   type = datatype(data)   - type is assigned the value returned by the datatype 
                              function; if function input variable data is:
                               - numeric, the returned value is NUM 
                               - a character string, the returned value is CHAR 

Variables are not explicitly typed. For example, a variable might be assigned a numeric value in one part of the macro, but later be assigned a character string value.


Perform Arithmetic Expressions in Editor Macros
Perform REXX Functions in Editor Macros