next up previous contents index
Next:   DIFFRACTION PATTERN Up: The KEYBOARD INTERFACE: Command Previous:   DEDUCE FILE SEQUENCE


  DEFINE VARIABLE

Internal program variables may be defined using the DEFINE VARIABLE command. This is similar to the Unix `alias' command, or the VMS `DEFINE' or `ASSIGN' commands. A ``token'' can be defined as a variable and given a data type and a value. The variable names, data types, and ``values'' are stored in a variable translation table. Once defined, whenever the variable is encountered, it will be replaced by its ``value'', prior to further input processing. The variable must be separated from other characters by one or more spaces, a comma, or a $<$TAB$>$.

This is very powerful, but also very dangerous, and potentially very confusing. Users are recommended to only use unlikely character strings for variables e.g. Start every variable with a hash sign (#). Certain commands define variables and values; these all start with a double hash (##).

Re-defining an existing variable will overwrite its previous value. If the data type changes a warning message will be output. Variables may be removed from the variable translation table by using the UN-DEFINE VARIABLE command (see Section 15.119, Page [*]). A list of currently defined variables, types, and values may be output using the LIST VARIABLES command ((see Section 15.54, Page [*]).

Variables may be used as a manner of ``parametrising'' a macro. By pre-defining variables for file names, variables may be used within a macro. By re-defining the variables with different file names the macro may be re-run on different files. Variables are further explained in Section 30, Page [*] and in particular an example is given of defining variables for ``parametrising'' a macro in Section 30.4, Page [*].

Here is an simple example of setting the variable #VALUE to store a floating point real value will be value of 0.7071. It may be noticed that the choice of data types is unique in the first character so single letters can be entered to set the data type.

Main menu: ENTER COMMAND [INPUT DATA]:define
ENTER NAME OF VARIABLE [#IN]:#VALUE
ENTER DATA TYPE OF VARIABLE:?
BOOLEAN VALUE: (Same as ``LOGICAL (BOOLEAN) VALUE'')
CHARACTER STRING VALUE: Alpha-numeric character string value
FLOATING POINT (REAL) VALUE: Floating point value
INTEGER VALUE: Store as an integer value
LOGICAL (BOOLEAN) VALUE: Logical ``true'' or ``false'' value
REAL VALUE: (Same as ``FLOATING POINT (REAL) VALUE'')
STRING VALUE: (Same as ``CHARACTER STRING VALUE'')
ENTER DATA TYPE OF VARIABLE:r
ENTER FLOATING POINT VALUE:0.7071


next up previous contents index
Next:   DIFFRACTION PATTERN Up: The KEYBOARD INTERFACE: Command Previous:   DEDUCE FILE SEQUENCE
Andrew Hammersley
2004-01-09