DIM Examples


Example 1:

 

TODAY

DIM

6

 

TODAY is blank filled, has a Physical Length of 6, a Form Pointer of 0, and a Length Pointer of 0.

 

Example 2:

 

TODAY

DIM

%6

 

TODAY is blank filled, has a Physical Length of 6, a Form Pointer of 0, a Length Pointer of 0, and is placed in the Global Data Area.

 

Example 3:

 

TABLE1

DIM

15(20)

 

TABLE1 is a character string array with 20 elements, TABLE1(1) through TABLE1(20)that are not initialized. Each array item is blank filled with a Physical Length of 15, a Form Pointer of 0, and a Length Pointer of 0.

 

Example 4:

 

TABLE2

DIM

1(2,2),("A"),("B"),("C"),("D")

 

TABLE2 is a two-dimensional array with 4 elements (2,2) each with a Physical Length of one and initialized as follows: TABLE2(1,1) equals A, TABLE2(1,2) equals B, TABLE2(2,1) equals C, and TABLE2(2,2) equals D.

 

Example 5:

 

STATES

DIM

2(50),("AK"),("AR"),("AZ"),...("WA")

(or)

 

 

STATES

DIM

2(50),("AK"):

  

  

(65,0102): (valid control codes)

  

  

(0x41,"Z"):(combination code and literal)

  

  

etc...(up to the 50 defined array items)

 

STATES is a character string array with 50 elements, STATES(1) through STATES(50)that have been initialized. The initialization data, inside the parentheses and quotes if a literal or parentheses only if a control code, is moved into the corresponding array item in the order given. If insufficient initialization contents are given for the array items specified, any remaining array items are treated as an uninitialized array item. Otherwise, each array item has a Physical Length of two, a Form Pointer set to one and a Length Pointer set to the last character of the initialized contents.

 

Example 6:

 

ARR1

DIM

20(3):

A1

  

("ABC"):

A2

  

("DEF"):

A3

  

("XXX")

 

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

 

Example 7:

 

SIZE

EQU

35

SVAR

DIM

SIZE

NAME

DIM

SIZE

 

SVAR and NAME are both set equal to the length of SIZE.

 

Example 8:

 

BUFFER

DIM

32767

 

BUFFER is blank filled, has a Physical Length of 32767, a Form Pointer of zero and an Length Pointer of zero.

 

Example 9:

 

PTRDIM

DIM

^

DIM1

DIM

40

DIM2

DIM

24

  

...

 

  

CALL

SUB USING DIM1

  

CALL

SUB USING DIM2

  

...

 

SUB

LROUTINE

PTRDIM

  

...

 

  

KEYIN

*EDIT,*RV,PTRDIM

  

...

 

  

RETURN

 

 

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

 

Example 10:

 

DimArray

DIM

6[3], INITIAL "123", "abc", "xyz"

DimArr

DIM

[3]@

;Array of 3 pointers

DimArrPtr

DIM

@[]

;Array Pointer 1 dimension

Dim2ArrPtr

DIM

@[,]

;Array Pointer 2 dimensions

Dim3ArrPtr

DIM

@[,,]

;Array Pointer 3 dimensions

.

 

 

 

  

MOVEADR

DimArray, DimArrPtr

 

  

DISPLAY

DimArrPtr(2)

 

 

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

 



PL/B Language Reference DFREE Examples DISABLEITEM Example