TAL Programmer's Guide
Using Parameters
Using Procedures
096254 Tandem Computers Incorporated 11–33
Pointer Content as Reference Parameters
To pass the content of a pointer, prefix the pointer identifier with @ in the actual
parameter list. The called procedure can then change the pointer content in the caller.
An example is:
INT .array1[0:99]; !Declare ARRAY1
INT .array2[0:99]; !Declare ARRAY2
PROC proc1 (wptr);
 INT .wptr; !Declare WPTR (formal parameter)
 BEGIN
 wptr := @array2[0]; !Assign address of ARRAY2[0] to WPTR
 END;
PROC proc2 MAIN;
 BEGIN
 INT .my_ptr := @array1[0];
 !Declare MY_PTR; initialize it with address of ARRAY1[0]
 array1[0] := 100;
 array2[0] := 200;
 !MY_PTR = 100 before the following CALL statement
 CALL proc1 (@my_ptr);
 !MY_PTR = 200 after the preceding CALL statement
 !Avoid the following CALL statement:
 CALL proc1 (@array1);
 !ARRAY1 now refers to ARRAY2; previous ARRAY1 value is lost
 END;
Initializing Pointers Passed as Parameters
Before passing pointers as parameters, be sure they contain addresses:
INT .iptr; !Declare IPTR
INT ivar := 0; !Declare and initialize IVAR
PROC p (fiptr);
 INT .fiptr; !Declare FIPTR
 BEGIN
 fiptr := 2;
 END;
PROC m MAIN;
 BEGIN
 CALL p (iptr); !Not OK, IPTR is not initialized
 @iptr := @ivar; !Assign address of IVAR to IPTR;
 ! IPTR = 0 before the following call
 CALL p (iptr); !OK, PTR now contains an address;
 ! IPTR = 2 after the call
 END;










