AWebJS filename... [ PUBSCREEN public_screen_name ]
[ DEBUG ]
FILES/M/A,PUBSCREEN/K,DEBUG/S
The screen name in the PUBSCREEN argument is used to open any error requesters on, and the debugger window. By default these windows are opened on the default public screen.
If you set the DEBUG switch, the debugger is started when executing each file.
document
and window
are not available. Because it wouldn't make much sense
to run a program without any input or output facilities, AWebJS defines a couple
of predefined I/O functions.
write(expression1 [,expression2], ...[,expressionN]) writeln(expression1 [,expression2], ...[,expressionN])
write
function converts each expression to string, and outputs
the result to the standard output stream. Usually this will be the shell
window, unless you have redirected the output of AWebJS.
The writeln
function does the same as the write
function, but adds a newline after the last expression.
When you want to include your JavaScript program in an HTML document, you'll
have to use document.write
instead of just write
.
To avoid the need of changing your program again after you've completed
testing with AWebJS, use the following code fragment:
function Document() { this.write=write; this.writeln=writeln; } var document=new Document();Add these lines to the start of your program (and remove them before including the JavaScript program in your HTML document). Or save these lines in a separate file and specify the file as the first FILES argument on the AWebJS call.
By using this code fragment, you can use document.write
and
document.writeln
in your JavaScript program even when testing
with AWebJS.
readln()
readln
function reads a line from the standard input
stream and returns it as a string value. Usually the standard input stream
will be the shell window, unless you have redirected the input of AWebJS.
The string returned has a maximum length of 80 characters.
To start the debugger with every piece of JavaScript executed, you check the
Control / Debug JavaScript
menu option.
Alternatively, you can select the Debug
button from a run-time
JavaScript error requester to invoke the debugger.
In the top region of the debugger window, the current line number and the current code fragment is shown. "Code fragment" can be anything: a statement, a partial expression, or even an entire function. Note the code shown here is a result of decompilation, so it may look a bit different from the actual source code.
You control what is done next by clicking one button in the button row.
Over | Step over the current fragment. The current fragment is executed, and execution is halted again afterwards. |
---|---|
Into | Step into the current fragment. The first part of the current fragment is made the new current fragment. For example, if the current fragment is a compound statement (between braces, {...}), the first contained statement will become the next current fragment. If the current fragment is an assignment statement, the operand on the left-hand side of the assignment operator is made the next current fragment. Note: If the current fragment is atomic (like a number, or an identifier), execution is advanced one step. |
Test | Test the current fragment. The current fragment is executed, but execution is not advanced. The result of the current fragment is shown in the result field at the bottom of the debugger window. Note: this function has side effects! If the value of a variable is changed in the current fragment (like the = or the ++ operators), this change is permanent. |
Run | Run the program. The debugger window is closed, and execution is resumed without further interruption. |
Stop | Stop the program. The debugger window is closed and execution is cancelled. |