Decimal
This keyword declares a binary coded decimal value with up to 32 digits of precision.
Syntax
Local Decimal NAME
Local Decimal NAME(DIMENSIONS)
Variable Decimal NAME(DIMENSIONS)
Value Decimal NAME(DIMENSIONS)
Const Decimal NAME(DIMENSIONS)
NAME
is the name of the variable declared.DIMENSIONS
can be:- A single numeric value DIM, meaning that we have an array with an index range from 0 to DIM-1.
- A range of numeric values INDEX1..INDEX2, where the index varies between INDEX1 and INDEX2.
- Several indexes or index ranges separated by a comma. For multiple dimension arrays, up to four dimensions are possible.
Several variable declarations can be done on the same line, separated by a comma.
Local declarations create the variables in the current local variable class that is not seen by nested or calling subprograms. The Call / Subprog and func / Funprog insulate the local variables, as well as the calls of method by fmet.
Const, Variable, and Value declarations declare the arguments sent by a Call, func, or fmet. With these syntaxes, the dimensions and the index ranges can be omitted wherever the parenthesis is present. The dimension and index ranges are defined by the calling program.
Example
# Direct declarations
Local Decimal TURNOVER : # Local decimal variable
Local Decimal SALES_RESULTS(1..12), BENEFITS(1..12) : # Two arrays of 12 decimal values
# A sub-program computing a result from decimal values
Funprog COMPUTE_VALUE(AMOUNTS)
Variable Decimal AMOUNTS(,,) : # A 3 dimensions matrix of decimals is sent as reference
...
End SEND_STATUS
# A sub-program storing decimals
Subprog STORE_VALUES(TURNOVER)
Value Decimal TURNOVER(1..20) : # An array of 20 elements is sent (a copy is done when passing the arguments)
...
End
Comments
There is still a Global declaration variable that exists for variables that have to be seen in the scope of a process execution, but its use is strongly discouraged.
Implicit data type conversion
The Decimal data type will implicitly convert Tinyint, Shortint, Integer, Double and Float to a Decimal.
...
Local Decimal MY_DECIMAL # Declare decimal
MY_DECIMAL = 4294967295^2 # MY_DECIMAL= 18446744065119617025
See also
Global, Local, Variable, Value, Const, Tinyint, Date, Shortint, Integer, Float, Double, Char, Clbfile, Blbfile, Uuident, Datetime, Instance.