FORM
ANSI
The FORM instruction defines a decimal numeric variable or an array of such. If an array is defined, each array item may be initialized. It uses one of the following formats:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Where:
label
Optional. A Data Definition Label.
%
Optional. Denotes the item as being GLOBAL.
%%
Optional. Denotes the item as GLOBAL but does not initialize it in any way.
*
Optional. Denotes the item or file as being COMMON.
size
Required. A decimal constant or EQUATEd value indicating the variable size. The size is specified as the number of integer digits, followed by an optional decimal point and optional number of fractional digits.
value
Required. A numeric Literal (i.e., "3.45").
dvalue
Required. A decimal immediate value or a numeric literal.
arraysize
Optional. An integer decimal constant, CONST variable or EQUATEd value indicating the number of array items.
target
Optional. A previously declared FORM variable that initializes the array.
^
Optional. Denotes the item as being a POINTER.
@
Optional. Denotes the item as being a POINTER.
variable
Required. The name of a previously defined variable of the same type.
Flags Affected: NONE
Note the following:
FORM variables have a value of 0 unless an initialized.
Formats (1), (3), and (6) initialize the variable, or each array item where applicable, to zero The given size is specified as the number of integer digits, followed by an optional decimal point and optional number of fractional digits.
Formats (2), (4), and (7) initialize the variable, or each array item where applicable, to {value}. The number of integer digits and fractional digits is determined by the number of integer digits and fractional digits in the {value}.
{value} must be a valid numeric string enclosed in quotes (""). If a fractional value is desired, it must be in a valid format (including the decimal) within {value}.
Formats (5) and (8) define numeric arrays that are initialized with the values specified by {value} in the order given. If the format of {value} is a different size or format than the declared format and significant data is lost, a compilation WARNING occurs.
Multi-dimension arrays of up to fourteen dimensions (three-dimensions in ANSI mode) are supported.
Spaces are allowed in FORM definitions only if representing suppressed leading zeroes.
A FORM definition may only contain one decimal. In ANSI mode, a trailing decimal is not allowed.
Negative values are indicated by a minus sign (-) immediately preceding the most significant digit. A FORM definition may only have one minus sign. For example:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Decimal points, minus signs, and spaces are not valid without at least one digit.
The ^ denotes a Pointer Variable. If a decimal point immediately follows the ^, the compiler flags that variable as having a decimal point. This is to help clarify the action of a CALC instruction using pointers where the compiler generates different code depending on whether the fields have decimal places or not.
If the % form is used, the data item is placed in the Global Data Area. The variable is then available to other programs that also declared it with the percent form. Global Data Items are available with PLBCMP only.
If the %% form is used, the data label is placed in the Global Data Area but no initialization takes place if it has not already been defined in the Global Data Area. If an array data label is placed in the Global Data Area, when initialized, it must have the same number of elements in the array. Global Data Items are available with PLBCMP only.
If the * form is used, the data item is in common with other programs and all of the rules of COMMON must be followed.
If an array is defined, each element may have a label
Format (13) provides an alternative array initialization syntax. The {dvalue} in this format may be either a decimal immediate value without double quote characters or a numeric literal enclosed in double quotes. Support for Format (13) is enabled only when the compiler option zc=3 is used.
Format (14) provides an alternative FORM syntax to declare a one-dimensional array of FORM pointers.
The syntax formats for (15), (16), and (17) are used to declare a FORM array-pointer construct that can contain the address of a one-dimensional, two-dimensional, and three-dimensional FORM array, respectively. For example.
F1arr FORM 2(4) //one-dimensional array
F2arr FORM 2(3,4) //two-dimensional array
F3arr FORM 2(2,3,4) //three-dimensional array
.
pArr1 FORM @() //one-dimensional FORM array pointer
pArr2 FORM @(,) //two-dimensional FORM array pointer
pArr3 FORM @(,,) //three-dimensional FORM array pointer
.
MOVEADR F1arr, pArr1
MOVEADR F2arr, pArr2
MOVEADR F3arr, pArr3
See Also: Example Code, INTEGER, Numeric Strings, Data Definitions
![]() |