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:
$\langle{\tt integer:1}\rangle$ an integer variable or constant
$\langle{\tt real:1}\rangle$ a real variable or constant
$\langle{\tt string:1}\rangle$ a string variable or constant
$\langle{\tt logical:1}\rangle$ a logical variable or constant
$\langle{\tt var\_:1}\rangle$ prefix for a variable
$\langle{\tt const\_:1}\rangle$ prefix for a constant
$\langle{\tt variable:1}\rangle$ $\langle{\tt var\_integer:1}\rangle$ | $\langle{\tt var\_real:1}\rangle$ | $\langle{\tt var\_string:1}\rangle$ | $\langle{\tt var\_logical:1}\rangle$
$\langle{\tt constant:1}\rangle$ $\langle{\tt const\_integer:1}\rangle$ | $\langle{\tt const\_real:1}\rangle$ | $\langle{\tt const\_string:1}\rangle$ | $\langle{\tt const\_logical:1}\rangle$
$\langle{\tt number:1}\rangle$ $\langle{\tt integer:1}\rangle$ | $\langle{\tt real:1}\rangle$
$\langle{\tt quantity:1}\rangle$ $\langle{\tt variable:1}\rangle$ | $\langle{\tt constant:1}\rangle$
$\langle{\tt quantity:0}\rangle$ a vector of any length with elements $\langle{\tt quantity:1}\rangle$
$\langle{\tt quantity:N}\rangle$ a vector of $N$ elements $\langle{\tt quantity:1}\rangle$


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-04-20