next up previous contents index
Next: TOP Commands Up: TOP, MODELLER scripting language Previous: TOP, MODELLER scripting language   Contents   Index

The source file

Each TOP program or include file is stored in a file named 'program.top'. The .top extension is mandatory.

The TOP program consists of a series of commands. The order of commands is important. An example of the TOP program that writes integers 1 to 10 to the output file is:

# Define a variable:
DEFINE_INTEGER VARIABLES = IVAR

# Open a file for appending
OPEN IO_UNIT = 21, OBJECTS_FILE = 'output.file', FILE_ACCESS = 'APPEND'

# Loop from 1 to 10:
DO  IVAR = 1, 10, 1
  # Append IVAR to the output file:
  WRITE IO_UNIT = 21, OBJECTS = IVAR
END_DO

# Close a file
CLOSE IO_UNIT = 11

# Exit:
STOP

There can be at most one command per line. Each command or line can be at most LENACT (2000) characters long. The command can extend over several lines if a continuation character `;' is used to indicate the end of the current line. Everything on that line after the continuation character is ignored.

A comment character `#' can be used anywhere on the line to ignore everything that occurs after the comment character.

Blank lines are allowed. They are ignored.

TAB characters are replaced by blank characters.

TOP converts all commands to upper case, except for the string constants that are quoted in single quotes '. Thus, TOP is case insensitive, except for the quoted strings.

There are two groups of commands: flow control commands and commands that perform certain tasks. The next two sections describe the flow control commands and those `performing' commands that are an integral part of TOP. There are also additional commands specific to each application of TOP, such as MODELLER and ASGL, which are described elsewhere.

The usual UNIX conventions are used for typesetting the rules. Table 4.1 explains the shorthand used to describe different variables and constants:


Table 4.1: List of variable types in TOP.
<integer:1> an integer variable or constant
<real:1> a real variable or constant
<string:1> a string variable or constant
<logical:1> a logical variable or constant
<var_:1> prefix for a variable
<const_:1> prefix for a constant
<variable:1> <var_integer:1> | <var_real:1> | <var_string:1> | <var_logical:1>
<constant:1> <const_integer:1> | <const_real:1> | <const_string:1> | <const_logical:1>
<number:1> <integer:1> | <real:1>
<quantity:1> <variable:1> | <constant:1>
<quantity:0> a vector of any length with elements <quantity:1>
<quantity:N> a vector of $N$ elements <quantity:1>


All the variables are formally vectors. When a variable is referred to in a scalar context its first element is used. All elements of one vector are of the same type. All variables, including a vector of the variable length, must have at least one element.

There are four different variable types: integer, real, string and logical.

The real constant is (FORTRAN real number representation):

  [+|-][digits][.][digits][{e|E|d|D}{+|-}digits]

The integer constant is (FORTRAN integer number representation):

  [+|-][digits]

The logical constant can be either on or off (case insensitive).

The string constant can contain any character except for a prime '. It can be optionally enclosed in primes. If it is not quoted it is converted to upper case and its extent is determined by the position of the blanks on each side of the contiguous string of non-blank characters.


next up previous contents index
Next: TOP Commands Up: TOP, MODELLER scripting language Previous: TOP, MODELLER scripting language   Contents   Index
Ben Webb 2004-10-04