EQUATE Examples


Example 1:

 

EIGHT

EQU

0b00001000

(binary = 8)

NINE

EQU

9

(decimal = 9)

TEN

EQU

0xA

(hex = 10)

ELEVEN

EQU

013

(octal = 11)

FIELD1

DIM

EIGHT

 

FIELD2

DIM

NINE

 

FIELD3

FORM

TEN

 

FIELD4

FORM

ELEVEN

 

NINE

EQU

"9",REDEFINE

 

 

This examples show some common uses for the EQUATE directive.

 

Example 2:

 

*

 

 

.Using EQUATE to set an array size

.

 

 

ARRSIZE

EQU

10

ARRAY1

FORM

5.2(ARRSIZE)

ARRAY2

FORM

5.2(ARRSIZE)

ARRSIZE

EQU

20,REDEFINE

ARRAY3

FORM

10(ARRSIZE)

ARRAY4

FORM

7(ARRSIZE)

 

To change the number of array elements, you need only modify the equated value of ARRSIZE.

 

Example 3:

 

ABC

DIM

5

 

.

 

 

 

ABC_EQU

EQU

DTYPE(ABC)

;Equated value for ABC type

ABC_TYPE

INTEGER

2,ABC_EQU

;Integer value for ABC type

ABC_PTR

EQU

PTYPE(ABC)

;Equated value for ABC pointer

.

 

 

 

  

%IF

DTYPE(ABC) = 32

 

  

DISPLAY

"ABC IS A DIM!"

 

  

%ELSE

DISPLAY "ABC IS NOT A DIM!"

 

  

%ENDIF

 

 

  

DISPLAY

"ABC TYPE VALUE IS:",ABC_TYPE

 

  

%IF

ABC_PTR = 0

 

  

DISPLAY

"ABC IS NOT POINTER!"

 

  

%ELSE

 

 

  

DISPLAY

"ABC IS POINTER!"

 

  

%ENDIF

 

 

 

 



PL/B Language Reference ENTERZ Example ERASE Example