1. Home
  2. SYNTAX directive

SYNTAX directive

Obtains details of the syntax of a command and the source code of a procedure.

No options

Parameters

COMMAND = texts Single-line texts specifying the commands
NOPTIONS = scalars Number of options for each command
NPARAMETERS = scalars Number of parameters for each command
NAME = texts Names of the options, and then the parameters, of each command
MODE = texts Modes of the options and parameters
NVALUES = pointers Number of values allowed for the options and parameters
VALUES = pointers Allowed values for the options and parameters
DEFAULT = pointers Default values for the options and parameters
SET = texts Whether the options and parameters must be set
DECLARED = texts Whether the options and parameters must have been declared
TYPE = pointers Allowed types for the options and parameters
COMPATIBLE = pointers Aspects of the options and parameters that must be compatible with the first parameter
PRESENT = texts Whether the options and parameters must have values
LIST = texts Whether the options have more than one setting (not relevant for the parameters
INPUT = texts Whether the options and parameters only supply input information
DEFINITION = texts Saves statements to define the syntax
SOURCE = texts Saves the source code of a procedure

Description

SYNTAX enables you to obtain details about the syntax of a command (i.e. a directive or a procedure). The name of the command must be supplied in a single-value text, using the COMMAND parameter. The NOPTIONS parameter gives its number of options, and the NPARAMETERS parameter gives the number of parameters.

The other parameters give details of the options and parameters. These correspond to the parameters of the OPTION and PARAMETER directives.

The NAMES parameter saves a text containing the names of the options (if any), followed by the names of any parameters.

The MODE parameter saves a text giving the modes of the options and parameters: whether their settings should be a number (v), or an identifier of a data structure (p), or a string (t), or an expression (e), or a formula (f). These codes are exactly the same as those that indicate the mode of the values to appear within the brackets containing an unnamed structure.

The NVALUES saves a pointer defining how many values the structures that are supplied for options and parameters of mode p may contain. The element of the pointer is a scalar there is only one possibility, and a variate if there are several.

The VALUES saves a pointer containing the allowed set of values that may have been defined for options and parameters with modes t and v. The element of the pointer will be a text for an option or parameter of mode t, and either a scalar or a variate for an option or parameter of mode v.

The DEFAULT parameter saves a pointer containing the default settings that may have been defined for the options and parameters with modes t and v.

The SET parameter saves a text containing ‘yes‘ or ‘no‘ according to whether or not the options and parameters must be set.

The DECLARED parameter saves a text containing ‘yes‘ or ‘no‘ according to whether or not the options and parameters of mode p must be set to a data structure that has already been declared.

The TYPE parameter saves a pointer containing a text to indicate the allowed types of the structures to which each option and parameter of mode p can be set.

The COMPATIBLE parameter saves a pointer containing a texts to specify aspects of the options and parameters that must be compatible with the first parameter.

The PRESENT parameter saves a text containing ‘yes‘ or ‘no‘ according to whether or not the options and parameters must be set to a data structure that has values.

The INPUT parameter saves a text containing ‘yes‘ or ‘no‘ according to whether or not the options and parameters are be used only to provide input to the command.

The DEFINITION parameter can save statements, in a text, to define the syntax. These start with a DEFINE statement for a directive or a PROCEDURE statement for a procedure, then an OPTION statement to define any options, and a PARAMETER statement to define any parameters.

The SOURCE parameter can save the source code of a procedure. This can be useful if you have a library containing the procedure, but no longer have the original source file. Note, though, that the source that you save will not be identical to the original source. When procedures are defined within Genstat, their source code is processed to remove comments and extraneous spaces in order to save storage space.

Parameters: COMMAND, NOPTIONS, NPARAMETERS, NAME, MODE, NVALUES, VALUES, DEFAULT, SET, DECLARED, TYPE, COMPATIBLE, PRESENT, LIST, INPUT, DEFINITION, SOURCE.

See also

Directives: COMMANDINFORMATION, OPTION, PROCEDURE.
Procedures: SPSYNTAX.
Commands for: Program control.

Example

" Example 1:5.3.2, 1:5.4.5, 1:5.4.6 "
PROCEDURE '%TRANSFORM'
" Define the arguments of the procedure."
  OPTION NAME='METHOD'; MODE=t; \
    VALUES=!t(Logit,Comploglog,Angular); \
    DEFAULT='LOGIT'
  PARAMETER NAME='PERCENT','RESULT'; \
    MODE=p; SET=yes; DECLARED=yes,no; \
    TYPE=!t(scalar,variate,matrix,symmetric,diagonal,table);\
    COMPATIBLE=*,!t(type,nvalues); \
    PRESENT=yes,no
  IF METHOD .EQS. 'Logit'
    CALCULATE RESULT = LOG( PERCENT / (100-PERCENT) )
  ELSIF METHOD .EQS. 'Comploglog'
    CALCULATE RESULT = LOG( -LOG((100-PERCENT)/100) )
  ELSIF METHOD .EQS. 'Angular'
    CALCULATE RESULT = ANGULAR(PERCENT)
  ENDIF
ENDPROCEDURE

VARIATE    [VALUES=10,20...90] Every10%
" default setting 'logit' for METHOD "
%TRANSFORM Every10%; RESULT=Logit10%
PRINT      Every10%,Logit10%; DECIMALS=0,3
%TRANSFORM [METHOD=A] 25,50,75; RESULT=Ang25,Ang50,Ang75
PRINT      Ang25,Ang50,Ang75

COMMANDINFORMATION '%TRANSFORM','CAPTION','DOTPLOT','NOTONE';\
  IMPLEMENTATION=tranimp,capimp,dotimp,notimp;\
  CHANNEL=tranchan,capchan,dotchan,notchan;\
  PRESENT=trancheck,capcheck,dotcheck,notcheck
PRINT tranimp,tranchan,trancheck
&     capimp,capchan,capcheck
&     dotimp,dotchan,dotcheck
&     notimp,notchan,notcheck

SYNTAX '%TRANSFORM'; NOPTIONS=nopt; NPARAMETERS=npar; NAME=names;\
       MODE=modes; NVALUES=nvals; VALUES=values; DEFAULT=default;\
       SET=set; DECLARED=declared; TYPE=types; COMPATIBLE=compat;\
       PRESENT=present; LIST=list; INPUT=input; SOURCE=source
PRINT  nopt,npar; DECIMALS=0
&      names,modes,set,declared,list,input,present;\
       FIELD=*,6,4,9,5,6,8; JUST=left,6(right)
FOR [INDEX=i; NTIMES=nopt+npar]
  IF NMV(NVALUES(nvals[i]))
    ASSIGN 'No nvals'; POINT=nvals; ELEMENT=i
  ENDIF
  IF NMV(NVALUES(values[i]))
    ASSIGN 'No values'; POINT=values; ELEMENT=i
  ENDIF
  IF NMV(NVALUES(default[i]))
    ASSIGN 'No default'; POINT=default; ELEMENT=i
  ENDIF
  IF NMV(NVALUES(types[i]))
    ASSIGN 'No types'; POINT=types; ELEMENT=i
  ENDIF
  IF NMV(NVALUES(compat[i]))
    ASSIGN 'No compat'; POINT=compat; ELEMENT=i
  ENDIF
ENDFOR
PRINT  [SQUASH=yes; ORIENT=across] nvals[]
&      values[]
&      default[]
&      types[]
&      compat[]
PRINT  source; JUST=left
Updated on October 29, 2020

Was this article helpful?