$SUB (subtraction)
$SUB performs subtraction, treating character strings as numeric values, and returns the arithmetic result.
Syntax
return-value=$SUB(character-string,numeric-character)
Values
-
return-value
Specifies the name of the variable into which the arithmetic result is set. Valid results range from 0.0001 to 999,999,999,999,999 (15 digits).
-
character-string
Specifies a minuend, either as a constant or a variable. A constant must be enclosed in single quotation marks (''). Specified values can range from 0.0001 to 999,999,999,999,999 (15 digits).
-
numeric-character
Specifies a subtrahend, either as a constant or a variable. A constant must be enclosed in single quotation marks (''). Specified values can range from 0.0001 to 999,999,999,999,999 (15 digits).
Status
The following table lists and describes the possible statuses:
Status |
Description |
---|---|
NORMAL |
Normal end |
NODATA |
Indicates one of the following:
|
ERROR |
— |
Script execution interrupted |
An invalid argument was specified, or an error other than the above occurred. |
- Legend:
-
—: Not applicable
Remarks
If a value that cannot be specified in character-string or numeric-character is encountered, or if the arithmetic result is a value outside the representable range, 0 is returned to return-value.
Example
The following example calculates 10 - 5 and outputs the result:
[SET_VALUE] VAL1 = 10 VAL2 = $SUB(VAL1, 5) MSG = 'SUB:' +VAL1+ ' - 5 = ' +VAL2 $ECHO(MSG)
- Execution result:
-
SUB: 10 - 5 = 5