next up previous contents index
Next: Example: A Conditional Up: X-PLOR Language Previous: Example

Control Statements

In general, a statement in X-PLOR can be a control statement   or an application statement .

<X-PLOR-statement>:==
<control-statement>
<application-statement>

A control statement allows structured control of the sequence of application statements, such as loops, and conditional tests. It also allows switching the input stream to another file, opening and closing files, and various other operations.

<control-statement>
:==
@<filename>
  deals with the fact that initially the parser reads from standard input (which will be FORTRAN unit 5 in most cases). The stream can be switched to another file by using this statement. Upon end of file, the parsing stream is switched back to the previous input. Nested streams are allowed.
@@<filename>
  has the same effect as the ``@" statement, except when the stream file is invoked within a structured loop statement. In this case, the ``@" statement inserts the contents of file filename into the loop and removes the statement in subsequent loop cycles, whereas the ``@@" statement reads from filename each time the loop hits the statement. It should be noted that filename can be a symbol. This allows one to loop through a set of different filenames. Nested ``@@" statements are allowed in this release of X-PLOR.
CLOSe
<filename> DISPosition=KEEP|DELEte END explicitly closes a specified file. Normally this operation is done automatically by X-PLOR, so this statement should be used only in rare cases, such as closing and deleting a file.
DISPLAY <record>
  writes the record to a file that is specified by the ``SET DISPlay" statement. The record can be any sequence of characters terminated by a carriage return. It may contain symbols that are substituted before the record is written to the file.
EVALuate <evaluate-statement>
manipulates symbols (see Section 2.14).
FOR
  <symbol> IN ( { <word> } ) <basic-loop> assigns the symbol to a word from the specified set of words (one at a time) and executes the statements within the basic loop.
FOR
<symbol> IN ID <selection> <basic-loop> assigns the symbol to the internal atom identifier for all atoms in the selection, and executes the statements within the basic loop (cf. Section 2.15). Care should be taken not to modify the molecular structure within the scope of the basic loop. The selection for the symbols is stored and computed when the loop is initialized, and it is not mapped when atom numbers change.
IF
  <condition> THEN <X-PLOR-statement>
[{ ELSEIF <condition> THEN <X-PLOR-statement> }]
[ ELSE <X-PLOR-statement> ] END IF
depending on the conditions, sends control flow to the appropriate branch.
OPEN <filename>
FORMatted = FORMATTED | UNFORMATTED ACCESS = READ | WRITE | APPEND END explicitly opens the specified file. Normally, this operation is done automatically by X-PLOR, and so the statement should be used only in rare cases, such as opening a file with append access.
REMARKS <record>
  writes the record to an internal title store. The record can be any sequence of characters terminated by a carriage return. It can contain symbols that are substituted before the record is stored. The internal title store is written to the first lines of output files.
REWInd <filename> END
rewinds the specified file.
SET <set-statement> END
sets various global parameters and options (see Section 2.13).
WHILe
  <condition> <basic-loop> while the condition is true, executes the statements within the basic loop.

<condition>
:== ( <word> GE|LE <word> ) specify that a condition is true if the first word is equal to, not equal to, greater than, less than, greater than or equal to, or less than or equal to the second word, respectively.
<basic-loop>
:== LOOP <label> { <X-PLOR-statement>
[EXIT <label>] } END LOOP <label>
represents a basic body of a loop. The label is a string with up to four characters. The EXIT statement allows jumping out of the specified loop (should be part of a conditional statement). Loops may be nested.





next up previous contents index
Next: Example: A Conditional Up: X-PLOR Language Previous: Example



Web Manager
Sat Mar 11 09:37:37 PST 1995