Until this year, all our models Virtual Economy, the Virtual Learning Arcade simulations and the BBC Budget Day tax calculator ran on Web servers. This is great for ease of access. As we enthused in an article published back in 1995 when we were just starting off, anybody, no matter what machine or operating system they have, can interact with a server-side model as long as they have a suitable browser.
If you want to see our example, you can download the source from our Virtual Worlds site. Instructions on how to use it are included on the page. To run the program, go to this year's BBC version or our copy, linked from the Virtual Worlds page (see References).
very easy to create records for example, a structure
representing a book, with fields for author, title and ISBN,
or a pair representing a complex number, with real and
imaginary components. Arrays and lookup tables are also
straightforward. But again, there is little compile-time
checking. You might intend your
book record to have a
Author, but the compiler won't tell you if you
So the second form then gets displayed. With this form, there is an issue of data validation because if you type, for example, a letter where a number is expected, we have to make sure it doesn't get into the model and crash it. (The old server-side input form side-stepped this problem by using menus.) We do two kinds of validation. It's possible to check some things as soon as the user types a character: letters never make any sense in a numeric field, and neither do most other non-digit characters, so we can reject those straight away. However, some checks have to be left until the form is finally submitted. For example, blank fields aren't valid. But we can only reject a field if it's blank at the time the form is submitted, not if it becomes blank while the user is typing: in the latter case, the user might just be in the process of retyping a number.
The obvious way is by loading it into the browser. Create
the file (or files) that is to be your final Web page, with your
and then open it from the browser. If you don't have a Web
server, the browser will probably let you type the filename
into the address bar, preceded by the prefix
When you test code in a browser, be warned! Our
browsers were truly dreadful at reporting errors, frequently
just displaying a blank page if there was something awry
in the code. This is frustrating, but there is a way to trace
how far the browser has got. Sprinkle the page liberally
with calls to the
alert function. This displays a dialogue
box when called, and can be used for debugging in the
same way you'd use a print statement in other languages.
When developing complicated code, we favour a different
approach Rhino. This is an open-source Java
http://www.mozilla.org/rhino/ . If you have Java, Rhino is
easy to install. The Rhino documentation tells you how to
invoke the interpreter; doing so will pop up a window
be simple arithmetic expressions Rhino makes a handy
Rhino knows about. You can load one of your own files
by calling its
load function, and once you've done this, all
the functions defined in it become available, so you can
test them by trying them out with various arguments. What
you can't do, since Rhino isn't embedded in a browser, is
pages. But any kind of Web-based model will contain a lot
of functions that have nothing at all to do with output
such as Ready Reckoner's tax calculations and we do
recommend getting these tested and working under Rhino
first, before starting with the others.
As well as intentional differences in implementation, browsers also suffer from bugs, which can cause a lot of grief until you realise what's going on. The most comprehensive site we have found for this is a German one, and for those who can read German, we give the URL: it's at http://www.browser-bugs.de/ .
The URLs here were checked on 20 June 2003.
Kobert, T., Seeboerger-Weichselbaum, M. and Spona, H., 'Browser bugs' (in German), http://www.browser-bugs.de/ .
Paine, J. and Stark, G., 'BBC Budget tax calculator', http://www.virtual-worlds.biz/rr_source/ .
136 Hainault Avenue
Milton Keynes, MK14 5PG
Tel: (+044) 01908 618239