Symbols are GQEs that consist of a name and a value. They can be used as variables or as shorthands for commands. The value of a symbol is always a character string which is interpreted as text or a number depending on the subroutine which actually uses the symbol.
A "=" which appears as the second token of a command string identifies a command as a symbol assignment (the definition of the term "token" is given in section 5.2). The first token is the symbol name and the rest of the line behind the "=" is the value:
SPECTRA>
symbol = value
Symbol names must not begin with a digit.
Symbols, which are created this way, are stored in descending order beginning in the last slot. If a symbol has to appear in a particular slot, the symbol() function has to be used (sect. 14.5.17):
SPECTRA>
symbol( id, symbol) = value
ID identifies the slot where the symbol goes.
Before a symbol is inserted into the queue, SPECTRA checks whether the symbol name matches one of the keywords. If it finds a match, a warning message is displayed. Users who want to avoid the re-definition of keywords enter the command:
SPECTRA>
set noredefine
The command
SPECTRA>
set redefine
restores the default status.
Symbol values can be read from the terminal:
SPECTRA>
inquire symbol prompt_string
SPECTRA displays the prompt_string and waits for the user
to enter the symbol value.
It is also possible to read a single character from the terminal
and store it in a symbol:
SPECTRAThe /keyw qualifier lets SPECTRA wait for the keystroke. If the /key qualifier is supplied, the program just reads the input buffer and carries on with the execution of the next statement.>
inquire/keyw symbol prompt_string
SPECTRA>
inquire/key symbol prompt_string
Symbols are deleted by omitting the value:
SPECTRA>
symbol =
If the value string contains significant blanks, it has to be enclosed in double quotation marks (Gänsefüßchen):
SPECTRA>
s1 = "dies ist ein test"
If there were no quotation marks, S1 would have the value "diesisteintest".
Symbols can be protected against further interpretation by putting them into square brackets:
SPECTRA>
s1 = [Energy [keV]]
Consider an additional unprotected symbol like:
SPECTRA>
txt = " set /text="
The command:
SPECTRA>
txt s1
translates the symbols and splits TXT into the verb SET and
the first part of a qualifier assignment /TEXT=.
The value of S1 "Energy [keV]" is kept as one token.
The inner square brackets are not removed.
It is also possible to create protected symbols with an inquire command:
SPECTRA>
inquire/protect sym_name ...
Symbol translation occurs in several places:
The following command line shows how symbols are concatenated:
SPECTRA>
sym1 = sym2"text1"sym3"text2"...
The text between the symbols can be omitted. e.g.:
SPECTRAThe last command line prints the string "guten morgen" on the terminal.>
s1 = guten
SPECTRA>
s2 = " morgen"
SPECTRA>
say s1""s2
Symbols can be used in arithmetic expressions and the result of a calculation can be stored in a symbol.
Example:
SPECTRAThe second command displays the symbol pi. If pi were not hidden between quotation marks, it would be translated during the parsing of the command line. That would result in the command " sh sy 3.14...". Symbol value can be inspected using the wild-card character, e.g. the command>
pi = 4atan(1)
SPECTRA>
sh sy "pi"
SPECTRA>
= -3
pi
displays the numeric result
SPECTRAlists all symbols that begin with the letter "p".>
sh sy p![]()
It is also possible to search for symbols which have a certain value: symbol_alias(). Here is an example:
SPECTRA>
two_theta = mot11
SPECTRA>
tt = mot11
SPECTRA>
= symbol_alias( mot11)
TWO_THETA, TT