Performing Variable Arithmetic and Numeric Comparisons

Top  Previous  Next

 

FileLink variables are always represented internally as string values. However, numeric operations can be performed on variables and strings as long as they contain only numeric (e.g., digits 0 - 9) values, or on numeric constants.

 

Numeric variables may be created using the SET or SETNUM command as shown below. When initializing variables, the only difference between SET and SETNUM is that SETNUM verifies that the variable is being set to a numeric value. Any previous value in the variable, regardless if it numeric or non-numeric, is discarded.

 

SET x = "100"

SETNUM x = 100

 

Numeric variables may be incremented and decremented using the INC and DEC commands as shown below.

 

INC x

DEC x

 

Basic integer arithmetic may also be performed on numeric variables using the SETNUM command. This command allows for addition, subtraction, multiplication, and division to be performed on two variables and/or numeric string constants as shown in the various statements below.

 

SETNUMSETNUM a = 100

SETNUMSETNUM x = a + a;; addition
SETNUMSETNUM x = a – 100;; subtraction
SETNUMSETNUM x = 100 x a;; multiplication
SETNUMSETNUM x = a / 100;; division

 

Numeric variables may be compared using one of the IFNUM commands as shown below.

 

IFNUM x 100 goto vars_equal

IFNUM< x 101 goto var_less_than

IFNUM> x 99 goto var_greater_than

IFNUM< x 101 goto var_less_than_or_equal

IFNUM> x 99 goto var_greater_than_or_equal

IFNUM! x 99 goto vars_not_equal