Debugging

Description

Judicial use of if() and two special commands can greatly assist you in debugging your programs.

report_var(var)

This command will pop up a message box telling you the value of the specified variable.
Read more.

lvar()

This command will insert a variables list into the debug log (RISC OS), or create a file listing the state of the script interpreter (Windows).
Read more.

Trace log (RISC OS)

If you have a RAMdisc defined, then the script interpreter will create a file called "ttxscrplog". Everything on line 2 of the report window will be written to this log. Ensure your disc is large enough, as running out of space for the log is classed as a script error (not intentionally, the script error handler picks it up).
To give you an idea, "movietest" generated a 66K log.
Line one (the upper line) is not logged, so you are spared loads of lines saying "Executing script - 69% (64)".

One thing to note, the line number reporting is not totally accurate. I patched this facility into the existing script interpreter to aid me in debugging (as percentages were a pain to figure out). It can get confused by lots of branching. :-)

Windows: The core functionality of the trace log is available, but it is not presented in the released versions of WinTTX because, to be honest, I found that a couple of report_var()s and an lvar() was all I really needed.

Because the Windows script interpreter was written with reporting in mind, the line numbers given are correct; and are correct for both RISC OS (LF only) and Windows (CRLF) format files.