Operators |
The information below describes the traditional operators (e.g. + - * /) you can use in PxPlus, along with other operators for which support has been added in recent versions (e.g. the auto-increment and decrement operators, assignment operators, the LIKE Operator, and the Apostrophe Operator).
See Numeric Values and String Values for additional information on the use of some of these operators.
The following operators are used to perform calculations:
+ |
Where: A + B adds A to B | |
- |
Where: A - B subtracts B from A | |
* |
Where: A * B multiplies A by B | |
/ |
Where: A / B divides A by B | |
^ |
Where: A ^ B raises A to the power of B (** is equivalent to ^) | |
| |
Where: A | B divides A's remainder by B |
The following assignment operators are included in the general syntax of the language:
Operator |
Meaning |
Description | ||||
+= |
Add To |
Can be used with numerics or strings. Example:
| ||||
-= |
Subtract From |
Not valid for strings. Example:
| ||||
*= |
Multiply By |
Can be used with numerics or strings. Example:
| ||||
/= |
Divide By |
Not valid with strings. Example:
| ||||
^= |
Exponentiation |
Raise to. Not valid with strings. Example:
| ||||
|= |
Modulus/Remainder from Division |
Not valid with strings. Example:
|
Increment and Decrement
In addition to the assignment operators, there are increment and decrement features:
++ |
Auto-increment (pre-increment when prefixed to variable name, post-increment if suffixed); e.g. ++variable or variable++. | |
-- |
Auto-decrement (pre-decrement when prefixed to variable name, post-decrement if suffixed); e.g.--variable or variable--. |
Example:
A=0, Y$=""
READ (1,IND=A++,ERR=*NEXT)X$; Y$+=X$; GOTO *SAME
or
Y$+=RCD(1,IND=A++,ERR=*NEXT); GOTO *SAME
See Labels/Logical Statement References.
Use the LIKE operator for string comparisons. The PxPlus default (with the 'TL' system parameter set to Off) is to take the string expression on the left and compare it to the string mask on the right. In the default mode, you can apply all the regular expression rules of the MSK( ) function to using the LIKE operator. Use the following format:
IF A$ LIKE "ABC" THEN ...
To make your conversions from Thoroughbred® easier, set 'TL' to On. With this parameter On, the LIKE operator emulates the Thoroughbred® matching of patterns.
See SET_PARAM directive, MSK( ) function and 'TL' system parameter.
The apostrophe operator is used to assign, retrieve, list, and make dynamic changes to a given control or object's properties.
For the syntax and use of the apostrophe, see Apostrophe Operator.
Thoroughbred® is a registered trademark of Thoroughbred Software International Inc.