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:

 

(1)

[label]

FORM

[%][*]{size}

(2)

[label]

FORM

[%][*]{value}

(3)

[label]

FORM

[%][*]{size}({arraysize})

(4)

[label]

FORM

[%][*]{value}({ arraysize})

(5)

[label]

FORM

[%][*]{size}({ arraysize}),({value}),..,({value})

(6)

[label]

FORM

[%][*]{size}({arraysize},..,arraysize})

(7)

[label]

FORM

[%][*]{value}({arraysize},..,{arraysize})

(8)

[label]

FORM

[%][*]{size}({arraysize},..,{arraysize}):

 

 

 

({value}),...,({value})

(9)

[label]

FORM

^

(10)

[label]

FORM

^[.][,{label}]

(11)

[label]

FORM

^({arraysize})[,({target}),...,({target})]

(12)

[label]

FORM

%%

(13)

[label]

FORM

[*][%]{size}({arraysize}), INITIAL {dvalue}, ..

(14)

[label]

FORM

({arraysize})@

(15)

[label]

FORM

[@|^]()

(16)

[label]

FORM

[@|^](,)

(17)

[label]

FORM

[@|^](,,)

 

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:

  1. FORM variables have a value of 0 unless an initialized.

  2. 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.

  3. 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}.

  4. {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}.

  5. 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.

  6. Multi-dimension arrays of up to fourteen dimensions (three-dimensions in ANSI mode) are supported.

  7. Spaces are allowed in FORM definitions only if representing suppressed leading zeroes.

  8. A FORM definition may only contain one decimal. In ANSI mode, a trailing decimal is not allowed.

  9. 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:

 

 

NEG10

FORM

"•••-10"

(valid format)

 

NEG10

FORM

"-•••10"

(invalid format)

 

NEG10

FORM

"----10"

(invalid format)

 

NEG10

FORM

"-10•••"

(invalid format)

 

  1. Decimal points, minus signs, and spaces are not valid without at least one digit.

  2. 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.

  3. 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.

  4. 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.

  5. If the * form is used, the data item is in common with other programs and all of the rules of COMMON must be followed.

  6. If an array is defined, each element may have a label

  7. 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.

  8. Format (14) provides an alternative FORM syntax to declare a one-dimensional array of FORM pointers.

  9. 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

 



PL/B Language Reference Numeric Variables BOOLEAN