1. Home
  2. ASSIGN directive

ASSIGN directive

Sets elements of pointers and dummies.

Options

NSUBSTITUTE = scalar Number of times n to substitute a dummy setting of the POINTER parameter in order to determine which dummy should be assigned the setting of the STRUCTURE parameter (if n is negative, the assigned dummy is the –nth from the bottom of the chain of dummies, like the NTIMES option of EXIT); default 0 i.e. no substitution
METHOD = string token Whether to replace or preserve the existing value in each dummy or pointer element (replace, preserve); default repl (note, pointer elements are never unset so METHOD=preserve with a pointer simply causes the assignment to be ignored)
RENAME = string token Whether to reset the default name for the structure if it has only a suffixed identifier (yes, no); default no
SCOPE = string token This allows dummies or pointer elements within a procedure to be set to point to structures in the program that called the procedure (SCOPE=external) or in the main program itself (SCOPE=global) rather than to structures within the procedure (local, external, global); default loca
NSTRUCTURESUBSTITUTE = scalar Number of times n to substitute a dummy setting of the STRUCTURE parameter in order to determine which structure to assign to the setting of the POINTER parameter (if n is negative, the assigned structure is the –nth from the bottom of the chain of dummies, like the NTIMES option of EXIT); default 0 i.e. no substitution

Parameters

STRUCTURE = identifiers Values for the dummies or pointer elements
POINTER = dummies or pointers Structure that is to point to each of those in the STRUCTURE list
ELEMENT = scalars or texts Unit or unit label indicating which pointer element is to be set; if omitted, the first element is assumed

Description

ASSIGN allows you to set individual elements of pointers, or to assign a value to a dummy. The parameter POINTER lists the pointers or dummies whose values you want to set; the values that you want to give them are listed by the STRUCTURE parameter. You pick out the individual elements of pointers by the ELEMENT parameter; a scalar identifies the element by its suffix number, while a text identifies it by its label. This example sets the dummy Yvar to point to the variate Height, and elements 1 and 2 of the pointer Xvars to Protein and Vitamin, respectively.

VARIATE Height,Protein,Vitamin

POINTER [NVALUES=2] Xvars

DUMMY Yvar

ASSIGN Height,Protein,Vitamin;POINTER=Yvar,2(Xvars);\

  ELEMENT=1,1,2

Element 1 is assumed unless you specify otherwise; so to set just Yvar we need only put

ASSIGN Height; POINTER=Yvar

Options NSUBSTITUTE and METHOD are likely to be most useful when setting dummies within a procedure. By setting METHOD=preserve, any dummies that are already set will have their existing settings preserved. Hence this provides a very convenient and effective way of making default assignments while leaving any explicit assignments unchanged. Suppose, for example, that a procedure has dummy arguments FITTEDVALUES, RESIDUALS and RSS available to save various aspects of the analysis, and that we wish to use these as working variables while calculating this information within the procedure. By specifying

ASSIGN [METHOD=preserve] LocalF,LocalR,LocalRSS;\

  FITTEDVALUES,RESIDUALS,RSS

any of the dummies that is not set when the procedure is called will be assigned to the corresponding local structure, either LocalF, LocalR or LocalRSS. Note, however, that elements of pointers cannot be unset; they will always point to some identifier, even if it is unnamed. Thus, ASSIGN has no effect on elements of pointers when METHOD=preserve.

The NSUBSTITUTE option is useful when you have dummies pointing to other dummies, in a chain. This can often happen when one procedure calls another, passing one of its own arguments as the argument to the procedure that it calls. A positive setting substitutes the dummies in the POINTER list the defined number of times in order to determine which dummy in a chain is to be assigned a value. Alternatively, you can set NSUBSTITUTE to a negative integer to specify the dummy to assign by counting up from the bottom of the chain of dummies, instead of down from the top.

Similarly, the NSTRUCTURESUBSTITUTE option is useful when you have a dummy as the setting of the STRUCTURE parameter. By default, it is the dummy itself that is assigned to the corresponding dummy or pointer in the POINTER list. However, you can set NSTRUCTURESUBSTITUTE, in the same way as NSUBSTITUTE, to substitute the dummy before making the assignment.

The RENAME option enables you to control what identifier is used for data structures in the rare occasions when your program contains structures that can be referred to by more than one suffixed identifier and which do not have identifiers in their own right.

Finally, the SCOPE option enables you to assign a dummy within a procedure to a structure in the program that called the procedure. The dummy will thus operate as though it was a dummy option or parameter, except that the decision about the structure that it references in the outer program has been made within the procedure instead of outside it. This facility allows you to define new data structures in the outer program; however, care needs to be taken to ensure that there is no conflict with any existing structures.

Options: NSUBSTITUTE, METHOD, RENAME, SCOPE, NSTRUCTURESUBSTITUTE.

Parameters: STRUCTURE, POINTER, ELEMENT.

See also

Directives: DUMMY, POINTER, PROCEDURE.

Commands for: Calculations and manipulation, Program control.

Example

" Example 1:4-9-1b "
SCALAR X,Y; VALUE=1,2
DUMMY  A,B,C,D; VALUE=B,C,D,X
ASSIGN [NSUBSTITUTE=-1] Y; A
PRINT C,D
Updated on June 20, 2019

Was this article helpful?