Introduction | Language Structure | IB Statements | File System | Comet 32 Runtime | Index |
In addition to these operations, there are may functions that operate on string and/or numeric data. For more information, see the Procedure Division documentation.
Also see the notes about Precedence.
Notes:
Also see the LET statement.
Example:
LENGTH 5.0 ! Declare the length for A, B, C LOCAL A, B, C ! Declare them as LOCAL variables . LET A = 500 ! Set the value for A LET B = 2000 ! Set the value for B LET C = A + B ! Add A and B, giving C
Notes:
Also see the LET statement.
Example:
LENGTH 5.0 ! Declare the length for A, B, C LOCAL A, B, C ! Declare them as LOCAL variables . LET A = 800 ! Set the value for A LET B = 200 ! Set the value for B LET C = A - B ! Subtract B from A, giving C
Notes:
Also see the LET statement.
Example:
LENGTH 5.0 ! Declare the length for A, B, C LOCAL A, B, C ! Declare them as LOCAL variables . LET A = 150 ! Set the value for A LET B = 25 ! Set the value for B LET C = A * B ! Multiply A and B, giving C
Notes:
Also see the LET statement.
Example:
LENGTH 5.0 ! Declare the length for A, B, C LOCAL A, B, C ! Declare them as LOCAL variables . LET A = 150 ! Set the value for A LET B = 25 ! Set the value for B LET C = A / B ! Divide A by B, giving C
The MOD operator is supported in Comet 504 and greater.
The syntax is:
numeric-value-1 MOD numeric-value-2Example:
10 MOD 3This operation returns a value of 1. Explanation: 10 divided by 3 equals 3 with a remainder of 1.
This algebraic order can be overridden with parentheses. In a numeric expression containing parentheses, operations inside the parentheses will be performed first, followed by the algebraic order previously described. Parentheses may be nested to any level in a numeric expression -- they will be performed from the inside to the outside.
FIRSTNAME$ + LASTNAME$You may concatenate string constants, string variables, and string functions. Here is an example of concatenating constants with variables:
"(" + AREACODE$ + ")" + PHONENUMBER$Note: The maximum number of characters in any string is 254. If a concatenation operation results in more characters than have been declared for a receiving variable, characters will be truncated on the right-hand side. THIS TRUNCATION WILL OCCUR WITHOUT WARNING OF ANY KIND.
Operation Internet Basic syntax ================================================================= Equal to EQ or = Not equal to NE or NOT= Greater than GT or > Greater than or equal to GE or >= Less than LT or < Less than or equal to LE or <= Contains Contains (Strings only) Soundslike Soundslike (Strings only)
Additional information:
See the ASCII chart.
IF A=B AND B=C THEN... ! Both conditions must be true IF A=B OR B=C THEN... ! Either condition may be trueIf AND and OR are combined in a relational expression, the AND operator takes precedence (i.e., it will be evaluated first). It is possible to override this precedence with parentheses, just like the precedence in numeric operations can be overridden.
For more information on relational operations and logical operations, see the IF statement.
Beginning with Comet 2004, logical operations are also supported on binary
expressions. The AND, OR, and XOR operators are available.
The AND operator performs a logical conjunction on two expressions.
AND compares identically positioned bits in two numeric expressions
and sets the corresponding bit in the result field. A result bit will
only be set to 1 if both of the corresponding bits in the expression fields
are 1. Otherwise the result bit will be 0.
For example:
C = A AND B
If A = 1010 (binary) and B = 0011 (binary), then C = 0010 (binary).
The OR operator performs a logical disjunction on two numeric expressions.
OR compares identically positioned bits in two numeric expressions and sets
the corresponding bit in the result field. A result bit will always be set to
1 unless the corresponding bits in both expression fields are 0.
For example:
C = A OR B
If A = 1010 (binary) and B = 0011 (binary), then C = 1011 (binary).
The XOR operator performs a logical exclusion on two numeric expressions.
XOR compares identically positioned bits in two numeric expressions and sets
the corresponding bit in the result field. A result bit will only be set to 1
if exactly one of the expression fields has a 1 bit set in the corresponding
position.
For example:
C = A XOR B
If A = 1010 (binary) and B = 0011 (binary), then C = 1001 (binary).