next up previous contents index
Next: Error Reporting Up: xicmanual Previous: Supplied Example 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 13.5. Preprocessor directives can be used to comment out blocks of lines.

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.

Note: This behavior was different in release 2.5.35 and before. In those releases, the script parser, when reading the following constructs, would assume that the construct occupies the rest of the current line of text. That is, the parser would stop reading after reading the construct, and anything that follows on the line would be ignored. However, this behavior could be modified if a semicolon (`;') followed the construct. In that case, the parser would continue reading after the semicolon, as if reading a new line.
goto label
statement
end
break [n]
continue [n]
return [statement]
function xxx(...)
endfunc
static ...
global ...
In addition ``preprocessor'' lines (#ifdef, #define, etc.) and comments have the same property, but any trailing semicolon is ignored.

In the current release, the parser will continue reading after most of these constructs, whether or not a semicolon is present. Thus, 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.

A semicolon will explicitly terminate a construct, and may be needed in rare cases where the parser has trouble interpreting the syntax. The only place where a semicolon is required is to terminate the static and global declaration lists, if further command text follows on the line.

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 D.1.1. The parser also supports user-defined functions.



Subsections
next up previous contents index
Next: Error Reporting Up: xicmanual Previous: Supplied Example Scripts   Contents   Index
Stephen R. Whiteley 2006-10-23