User Variables
User variables are variables you create and set within the command list. You can set user variables with an assignment statement or an &PAUSE control statement.
Assignment statements are explained in Assignment Statements.
The &PAUSE control statement halts the command list so that the operator can enter data, and picks up the value of the user variable from the operator when the command list continues. &PAUSE is described in &PAUSE Control Statement.
When you create user variables, observe the following rules:
- The first character must be an ampersand (&).
- The first character following the ampersand must be a letter or a symbol, not a number. Otherwise, it is treated as a parameter variable.
- The ampersand must be followed by 1 to 11 characters. A - Z, 0 - 9, #, @, and $ are valid characters.
- The value of the user variable can be 255 characters long. The maximum number of double-byte characters between the shift-out (X'0E') and shift-in (X'0F') control characters is 126.
- A user variable can have a numeric value that is 255 digits long, including the sign. However, if the value of the user variable is obtained using an arithmetic expression (for example, addition or subtraction), or if the user variable is used in an arithmetic expression, the user variable can have a numeric value between -2147483647 and 2147483647. The only characters you can use in a numeric value are 0-9. The numeric value can be immediately preceded by a character indicating whether the value is positive (+) or negative (-).
Note: A command list can create a user variable that has
already been defined as a control statement, control variable, or
built-in function. However, you cannot use the provided control
statement, control variable, or built-in function anymore in
the command list.
Table 1 shows some examples of user variable
names.
| Valid | Non-valid | Reason |
|---|---|---|
| &A | &2A | Is read as &2, a parameter variable |
| &USERNAME | &INVALIDUSERNAME | Too long |
| &@23456 | &A% | % is not a valid character |
The following example shows how to manipulate user variables in
assignment statements to set parameters and to communicate with the
operator.
&PAUSE VARS &ONE &TWO
&SUM = &ONE + &TWO
CLEAR
&WRITE >>> THE SUM OF &ONE + &TWO IS --->&SUM