compareNum()

The vgLib.compareNum() system function compares the contents of two numeric variables of the same type and determines whether the first is less than, equal to, or greater than the second.

vgLib.compareNum() is one of a number of functions maintained for compatibility with code migrated from VisualAge® Generator. New code can use standard EGL operators for these purposes.

Syntax

  vgLib.compareNum(
    var1 NumType in,
    var2 NumType in)
  returns (result NumType)
result
Integer variable (INT or BIN(9)) that receives one of the following values:
-1
var1 is less than var2.
0
var1 is equal to var2.
1
var1 is greater than var2.
var1
Any numeric or HEX variable.
var2
Any numeric or HEX variable.

Example

The following example illustrates the vgLib.compareNum() function:

myVar01, myVar02, result INT;
myVar01 = 4;
myVar02 = 7;

result = vgLib.compareNum(myVar01,myVar02); // result = -1

Feedback