FORM Examples


Example 1:

 

PAGECNTR

FORM

3

 

PAGECNTR is a FORM numeric variable with a Physical Length (PL) of three bytes and a value of zero.

 

Example 2:

 

INVTOTAL

FORM

5.2

 

INVTOTAL is a FORM numeric variable with a Physical Length (PL) of eight bytes and a value of zero (interpreted as five positions before and two positions after the decimal).

 

Example 3:

 

TOTAL

FORM

%6.2

 

TOTAL is a FORM numeric variable with a Physical length (PL) of nine bytes and a value of zero (interpreted as six positions before and two positions after the decimal). It is placed in the Global Data Area.

 

Example 4:

 

SALESTAX

FORM

"1.05"

 

SALESTAX is a FORM numeric variable with a Physical Length (PL) of four bytes and a value of 1.05. This variable has an internal format of 1.2.

 

Example 5:

 

SALES

FORM

10.2(10)

 

SALES is a FORM numeric array of 10 elements, each with a Physical Length (PL) of thirteen and a value of zero.

 

Example 6:

 

DISCOUNT

FORM

".05"(5)

 

DISCOUNT is a FORM numeric array of 5 elements, each with a Physical Length (PL) of three bytes and a value of .05.

 

Example 7:

 

BIAS

FORM

1.2(2,2),(".05"),("1.50"),(".75"),(".10")

 

BIAS is a two-dimensional FORM numeric array with four elements (2,2) each having a Physical Length (PL) of four bytes and initialized as follows: BIAS(1,1) equals .05, BIAS(1,2) = 1.50, BIAS(2,1) = .75, and BIAS(2,2) = .10.

 

Example 8:

 

ARR1

FORM

5(3):

A1

  

("10"):

A2

  

("20"):

A3

  

("30")

 

ARR1 is a numeric array with three elements. Each element of the array may be accessed using array subscripting or by its label.

 

Example 9:

 

LEFT

EQU

5

RIGHT

EQU

3

FEQU

FORM

LEFT.RIGHT

 

FEQU is a FORM numeric variable with a Physical Length (PL) of nine and a value of '0', interpreted as having five positions to the left of the decimal point and three positions to the right of the decimal point.

 

Example 10:

 

PTRFORM

FORM

^

FORM1

FORM

5.2

FORM2

FORM

7.2

  

...

 

  

CALL

SUB USING FORM1

  

CALL

SUB USING FORM2

  

...

 

SUB

LROUTINE

PTRFORM

  

...

 

  

KEYIN

*RV,PTRFORM

  

...

 

  

RETURN

 

 

PTRFORM is a Pointer Variable that contains the address of another FORM variable at execution time. This assignment is usually accomplished via the parameterized CALL instruction. Once initialized, PTRFORM may be used as any other FORM variable. It takes on all the attributes of the pointed to FORM variable.

 

Example 11:

 

FormArray

FORM

2.2[3], INITIAL 1.5, 2.5, 3.5

FormArr

FORM

[3]@

;Array of 3 pointers

FormArrPtr

FORM

@[]

;Array Pointer 1 dimension

Form2ArrPtr

FORM

@[,]

;Array Pointer 2 dimensions

Form3ArrPtr

FORM

@[,,]

;Array Pointer 3 dimensions

 

This example illustrates use of the SWDBC compatibility mode of the compiler (-zc=3).

 



PL/B Language Reference FORK Examples FPOSIT Examples