next up previous contents index
Next: Error Reporting Up: The Xic Scripting Language Previous: Introduction to Xic Scripts   Contents   Index

The Scripting Language

A script consists of command lines, each containing one or more syntactically complete statements. Lines may be continued by adding a backslash character at the end of the line, which ``hides'' the return character. Parentheses are used as delimiters to enforce execution order, and to enclose arguments to functions. Arrays of up to three dimensions are supported, with the array indices separated by commas and enclosed in square brackets. Array names are taken as addresses, and may be passed to functions, and used in arithmetic expressions. There are no address or pointer operators, however a pointer mechanism does exist.

If a line begins with the pound sign `#' the line will be ignored by the parser, unless the line contains a ``preprocessor'' directive, described in 18.8. Preprocessor directives can be used to comment out blocks of lines. The character sequence `//' at the start of a line also indicates a comment.

There is one ``special case'' comment, which must be the first non-blank line of a script file to have relevance:

#menulabel label

The label is a word or quoted phrase, which will appear on the button in the top level of the User Menu which executes the script. Otherwise, like any comment, the line is ignored.

Each line of a script generally contains one statement or clause, the entirety of which should be contained in the same logical line. Physical lines can be continued with a backslash character to form a single logical line. If the last character on a line is the backslash (" \ ") character, the line that follows will be logically appended, replacing the backslash.

The parser will parse the opening clause of a line, and if there is additional text, the parser will continue reading, until all text on the line has been processed. Thus, a single line can actually contain multiple statements. Each statement can be terminated with a semicolon (";") to explicitly terminate the statement. Almost always, this is optional, however there may be rare cases where explicit termination is needed to force the parser into a correct interpretation. The end-of-line will also act as a statement terminator, which is why a statement must appear in a single logical line.

With a couple of exceptions, an entire script can be given on a single line. This is not recommended, as line-numbered error messages would not mean much, and the debugger would be useless, however this facilitates creating complicated macros with the ``#define'' preprocessor directive, which must always expand to a single line.

The two exceptions are:

  1. Comments and preprocessor directives start with `#' and continue to the end of the current line. Preprocessor directives must be given at the start of a line, though comments can appear in a line where a new statement could appear. It is not possible to include (unrelated) command text after a comment or preprocessor directive in a line.

  2. The declaration lists that follow the static and global keywords must be terminated with a semicolon if a different construct (including a comment) is to appear on the same line following the static or global construct.

Scripts can interact with forms in HTML documents so that the form can be used as input for Xic scripts. This is often more convenient than issuing a sequence of prompts to the user for input. The forms interface makes use of the HTML viewer used with the help system.

There is an expanding library of internal functions which can be called from scripts, described in F.1.1. The parser also supports user-defined functions.

Identifiers (function and variable names) must start with an alphabetic character or underscore, and can contain digits. Characters other than alphanumerics and underscore are generally not accepted in identifiers and will cause syntax errors. Identifiers are case-sensitive.

next up previous contents index
Next: Error Reporting Up: The Xic Scripting Language Previous: Introduction to Xic Scripts   Contents   Index
Stephen R. Whiteley 2022-05-28