|
Let's look at the previous script in more detail:
SCRIPT tag
Vortex scripts start and end with <SCRIPT>
tags
denoting the language as Vortex.
Functions
Vortex script functions are declared with <A NAME=name>
tags, and end with matching </A>
tags; declared function
names are case-sensitive. When a script is run, the entry
function is executed, which is by default main
. All
scripts must have a main
function, so our example declares
one. There are other types of functions, such as builtin and user
functions, which we'll see later.
Statements
In this simple example we have no statements or function calls in
main
, but if we did they would closely follow HTML tag syntax.
Any text in a function that is not recognized as a Vortex call is
just printed out as-is. Thus our <BODY>
tags and text are
printed out.
Leading spaces are stripped from output lines. This allows
Vortex code to be indented for readability, but saves the network
bandwidth of sending lots of extra blank space. Any HTML comments
in the script are also ignored and not printed out.
Variables
Variables are referenced with a dollar sign, so the variable $REMOTE_ADDR
is printed out in this example. $REMOTE_ADDR
indicates what address your browser is on; Vortex
automatically sets this from the Web server's CGI environment.
Variable names in Vortex are also case-sensitive.
Errors
Any errors - eg. bad syntax, table not found, etc. - are printed
in HTML comments in the output. (They are also logged to the file
/usr/local/morph3/texis/vortex.log
, or c:\morph3\texis\vortex.log
under Windows.) The comments keep
the casual user from seeing the errors, yet allow programmers to
easily see them in context by viewing the HTML source. (In non-HTML
or compile mode, the comment tags are left out.) Our simple example
produces no errors, but here's a hypothetical one:
015 /scripts/test:178: Variable expected in the function vx_parse
Error messages have a standard format that tells us something
about the error. Each starts with a 3-digit code: numbers below 100
are errors, 100-199 are warnings, everything above is usually
informational. Here 015 tells us this is a usage (15) error (less
than 100). The script name and line number are given next, if
applicable: this error happened on line 178 of /scripts/test
. Then the message describing the error is given,
possibly with the internal C function that it occurred in (this is
useful for Thunderstone tech support).
Error messages are an important debugging tool. A script can
catch some of its own error messages to recover from them on the
fly; we'll cover that in the section on Dynamic Error Handling
.
|