The following example will initialize all elements of 3x3 matrix A with the exception of its diagonal elements A (1,1), A(2,2), and A(3,3):
DECLARE A(3,3) FIXED BIN INIT(*,(3)0,*,(3)0,*);
The following example will initialize all elements of array B to the value of the expression (X+10 ) where X is a procedure parameter.
SUB; PROCEDURE(X); DECLARE X FIXED BIN(15); DECLARE B(5) FLOAT BIN INIT((HBOUND(B,1))(X+10));
The following example demonstrates the usage of asterisk repeat factor and will initialize the entire array Z to the value of 1.0.
SUB1: PROCEDURE(DIM); DECLARE DIM FIXED BIN(15); DECLARE Z(DIM) FLOAT BIN(23) INIT((*)1.0);
The INITIAL CALL is used to initialize automatic, based, or controlled variables by calling an external entry. The following is an example.
TEST: PROCEDURE OPTIONS(MAIN); /* Initialize all elements of array TEN */ DECLARE TEN(10) FIXED BIN(15) INIT CALL INITIALIZE(ADDR(TEN),HBOUND(TEN,1)); INITIALIZE: PROCEDURE(P,DIM); DECLARE P POINTER, DIM FIXED BIN(15); DECLARE I FIXED BIN, ARRAY(1000) FIXED BIN(15) BASED; DO I = 1 TO DIM; P->ARRAY(I)=75; END; END INITIALIZE; END TEST;