1. Home
  2. Genstat Command Language
  3. Syntax of the command language

Syntax of the command language

Input to Genstat is known as a Genstat program. This is made up of statements each of which may use one of the standard Genstat commands (known as directives); alternatively, it may use a Genstat procedure, that is, a subprogram of statements. You can write your own procedures, or use those in the Library distributed with Genstat, or in the library provided at your site.

Whether the statement uses a directive or a procedure, the syntax is identical. First you give the name of the directive (or procedure), then options, and then parameters. Finally, you indicate the end of the statement, either by typing a colon or by ending the line (by typing <return>). Long statements can be continued onto succeeding lines by typing the continuation character (\) before <return>.

Some statements will have neither options nor parameters: for example

PAGE

to start a new page in output. Others may have no options: for example

PRINT STRUCTURE=X,Y; DECIMALS=0,2

prints the contents of data structures X and Y with zero and two decimal places respectively. In this statement, there are two parameter settings defining two lists running in parallel. Parameter settings are always in parallel like this, and are separated from one another by semicolons. Options are enclosed in square brackets, and set aspects that apply to all the (parallel) parameter values. They are also separated from one another by semicolons. For example

PRINT [CHANNEL=2; INDENTATION=5] STRUCTURE=X,Y; DECIMALS=0,2

prints X and Y to output channel 2 with a five-character indentation at the start of each line. Nearly all options, and some parameters, have default values chosen to be those required most often, and so will usually not need to be set.

Settings of options and parameters can be lists (as above), expressions or formulae. Lists may be of numbers (as with DECIMALS above), or identifiers (as with STRUCTURE) or strings. An identifier is the name that you give to a Genstat data structure (for example X or Y), and which you then use to refer to it in the program. They must start with a letter (for Genstat this means the alphabetic characters A to Z, in capitals or lower case, as well as the percent and underline characters) and then contain either letters or digits (the numerical characters 0 to 9); Genstat takes notice of only the first 32 characters. (This is the default in Releases 4.2 onwards, but you can use the SET directive to request that Genstat take notice of only the first eight characters as in earlier releases.) Where a list of identifiers provides input to a directive or procedure, you can put an expression instead; this will then be evaluated (to give a list of identifiers containing the results) before the directive or procedure is used. A string is a list of characters. Usually the start and end of the string must be marked by a single quote ('). Strings occur within the Text data structure. Also, the settings of some options and parameters are lists of string “tokens” that can be chosen from a defined list; these do not need to start and end with single quotes. The separator between items in lists is comma; spaces can be included anywhere between items but do not act as separators. Formal definitions of expressions, formulae, and all the other concepts of the Genstat language are in the Guide to the Genstat Command Language, Part 1, Section 1.2.

Names of directives, procedures, options and parameters are examples of Genstat system words. They can be given in capital or small letters (or in mixtures of both) and, provided you are only using directives and official Genstat Library procedures, they can always be abbreviated to four characters. The same rules apply to string tokens in directives and Library procedures. However, if you or your site have defined your own procedures, you may have chosen names that differ only in the fifth or subsequent characters. If you supply more characters, Genstat will check the name up to the 32nd character, and ignore any characters after that. (You can, however, use the SET directive to request that Genstat also ignores the ninth and subsequent characters, as in releases before 4.2.)

Names of options and parameters can often be abbreviated to fewer than four characters, and there are also rules by which the option or parameter name, with its accompanying equals character, can be omitted altogether. The most useful of these is that, if the first parameter of the directive is the one that comes first in the statement, then the name of the parameter can be omitted: for example

PRINT [CHANNEL=2; INDENTATION=5] X,Y; DECIMALS=0,2

as STRUCTURE is the first parameter of PRINT. The same rule holds for options:

PRINT [2; INDENTATION=5] X,Y; DECIMALS=0,2

as CHANNEL is the first option of PRINT. Full details of the rules are in the Guide to the Genstat Command Language, Part 1, Section 1.2.

A final point about the first parameter is that its setting determines the length of the parallel lists. The lists for other parameters will be repeated (or recycled) if they are shorter. (If they are longer, Genstat gives an error diagnostic.) For example

PRINT A,B,C,D; DECIMALS=0,2

prints A with zero decimal places, B with two, and then (recycling the DECIMALS list), C with zero and D with two.

Updated on March 5, 2019

Was this article helpful?