The WOM language is conceptually very sparse. To the Web author, most of the interesting behaviour lies in the objects provided by the run-time library. These include:
IntegerField
, RealField
, BooleanField
:
these accept various types of data value, with error-checking.
TextField
: as above, but no error-checking.
Menu
: this displays a menu and transmits the user's
selection to the server. The menu can hold a translation table, so that
as with MDDL (2.3),
the form can send a string, but the server can
translate this into a number before it is passed to a program. It is
also possible to add and delete menu options dynamically.
WOMForm
: This name is used to avoid shielding the HTML
FORM
command. It denotes the built-in class which contains
fields and other input elements and transmits their values to the
server.
ActionLink
:
This is a hypertext link which, when clicked on,
initiates some action via an internal OnSubmit
. It can be thought
of as a form with no contents other than some static text and a Submit
button.
Submit
: This is a Submit button. We define it just so the
author does not have to remember how to code these in HTML.
Text
: This is a region whose value can be set dynamically.
We gave an example earlier.
Hider
: This can hold a sequence of other objects, but
displays them only if a condition attribute is set. This makes it easy,
on a particular page, to switch between displaying various different
pieces of information, as with the Budget 95 input
form (Section 2.4).
Run
: The main attribute of a Run
is the name and
location of a program's .exe
file. The Run
runs it,
displaying the progress of the program so far.
File
: The main attribute of a File
is the name of a
text file. The File
displays it. By using this class together
with a Hider
and a Run
, it is easy to write a page that
runs a program and displays its results if it has finished running,
but otherwise shows a progress report on the current run.
Region
: This is like a File
, but also has attributes
giving start- and end-positions within the file. It displays the text
within this region. Using Region
, one can include large chunks of
text in a page without having to write them as explicit strings. The WOM
compiler does this in its output code, to save space.
The following example demonstrates some of these classes.
<HTML> <HEAD><TITLE>Model output</TITLE></HEAD> <BODY> <H1>Output</H1> <WOMForm> <Hider h1> <Run r program="d:\lg\lg2.exe z %ID %DIR"> </Hider> <Hider h2> <File file="d:\lg\output.html"> </Hider> <Submit value="Press to see progress or results"> <OnSubmit> (t) h1~hiding[t] = r~hasFinished[t] (t) h2~hiding[t] = not r~hasFinished[t] </OnSubmit> </WOMForm> </BODY> </HTML>
This page refers to the built-in classes Hider
, Run
and
File
. The page is intended to run the program
d:\lg\lg2.exe\
, and uses the Run
class for this. When an
instance of Run
is created, it runs the program named in its
program
attribute, passing the parameters after the program name
on the program's command line.
Run
s have a hasFinished
attribute which is true if the
program has finished running, but false otherwise. When a Run
is
displayed, it shows the progress reports that the program has sent so
far - we provide programmers with some Modula library routines for
writing these out. Hiders
have a hiding
attribute, and
display their contents (the stuff between <Hider>
and </Hider>
)
unless this is false. The first hider's hiding
attribute is
constrained by the first equation to
be the same as the Run
's hasFinished
attribute, i.e. it will hide its contents unless the program has
finished. So the first Hider
will display the program's progress
so far, until it finishes.
The second hider works the other way round. File
objects have a
file
attribute, and display the file whose name this holds. This
hider is constrained by the second equation: its hiding
attribute
is true only when the program has finished. So once that has happened,
it will display the program's output file.
To summarise, this page starts a program running when it is first created. It contains a form which, when submitted, sends back an updated version of itself. This will display the program's results if they are ready, otherwise the program's progress so far.