INTEGER Examples


Example 1:

 

WORKFLD

INTEGER

1

 

WORKFLD is a one byte INTEGER with a possible value of 0 to 255 (0x0 to 0xFF).

 

Example 2:

 

WORKFLD1

INTEGER

%1

 

WORKFLD1 is a one byte INTEGER with a possible value of zero to 255 (0x0 to 0xFF). It is placed in the Global Data Area.

 

Example 3:

 

WORKFLD2

INTEGER

%%

 

WORKFLD is an INTEGER field whose size is undefined. It is placed in the Global Data Area. Before it may be used in a program, another program that defines the actual size must be CHAINed to or LOADMODed in order to define the variable.

 

Example 4:

 

TEMPFLD

INTEGER

4,"4294967295"

 

TEMPFLD is a 4 byte INTEGER with an initialized value of 4,294,967,295 (0xFFFFFFFF).

 

Example 5:

 

INT1

INTEGER

1,"0"

INT2

INTEGER

2,"300"

  

MOVE

INT2,INT1

 

The above example results in INT1 equaling 44 with the appropriate flags set.

 

Example 6:

 

SIZE

EQU

2

INT1

INTEGER

SIZE

 

INT1 is initialized as a 2 position INTEGER.

 

Example 7:

 

PTRINT

INTEGER

^

INT1

INTEGER

2,"1"

INT2

INTEGER

2,"2"

  

...

 

  

CALL

SUB USING INT1

  

CALL

SUB USING INT2

  

...

 

SUB

LROUTINE

PTRINT

  

...

 

  

BRANCH

PTRINT OF #LBL1,#LBL2

  

...

 

  

RETURN

 

 

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

 

Example 8:

 

ARR1

INTEGER

2(3):

A1

  

("10"):

A2

  

("20"):

A3

  

("30")

 

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

 

Example 9:

 

IntArray

Integer

2[3], INITIAL 1, 2, 3

IntArr

Integer

[3]@

;Array of 3 pointers

IntArrPtr

Integer

@[]

;Array Pointer 1 dimension

Int2ArrPtr

Integer

@[,]

;Array Pointer 2 dimensions

Int3ArrPtr

Integer

@[,,]

;Array Pointer 3 dimensions

Int

Integer

"123"

;Default to 4 byte integer

 

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

 



PL/B Language Reference INSERTITEM Example LCMOVE Examples