Previous Section
Previous Section: Connecting to a Remote Host
Document HomeDocument Home
Next Section: Automated Script Execution
Next Section


Script Debugging

A useful feature of Wozterm is its debugging capability. This tutorial will demonstrate Wozterm’s debugging features using the script

Error.cmd

Loading Error.cmd

 
  1. Ensure Preferences>Trace Script Files and Preferences>Warn on implicit Hostcmd are the only options enabled.
  2. File>Open.
  3. Prepare for use by Copy/Pasting it into Wozterm from Section 6.1.3 or by typing it in manually.
  4. Error.cmd



Fixing Compilation Errors/Warnings

 
  1. Check the syntax of the script with either Script>Check Syntax or by hitting the Check Syntax Action Button. Errors will be found.
  2. The first error is the @strng error (line 00008). It is a good idea when debugging to begin with the first error found by the compiler, as other errors will tend to cascade from it. Edit the text @strng to be @string. File>Save.

Figure 4.6 - Debugging Screen

Debugging Screen

Item

Description

  1. Blue question mark at script compile indicates a warning

All lines that generate warnings during compilation are shown using a blue question mark. Note that the Messages Tab displays the warning "USER : Line 00006 : WARNING : Implicit host command" because there is no @ symbol at the beginning of the line. In this case there is a code error, however this warning will trigger if Options>Warn on implicit Hostcmd is selected and the current line is a valid host command or not.

  1. Red X at script compile indicates an error

All lines that generate errors during compilation are shown using a red X. Note that only the first error found will usually be of any value: initial errors tend to cascade through the compilation process. The user has made a typo in line 00008 using @strng instead of @string. This is the third compilation message reported in the Messages Tab.

  1. Messages Tab displays all compilation errors / warnings

As demonstrated in the above two screen descriptions, all compilation errors/warnings are displayed in the Messages Tab.

  1. Script Status displays compilation summary

Script Status in the Status Bar displays the number of errors and warnings generated during compilation. Note again that there are only two erroneous lines in this script: the other 18 errors have cascaded from them.


  1. The script now has 6 errors, however a check of the erroneous lines reveals that they are syntactically correct. The debugging information indicates that there should be a variable named ‘MAXFILELINES’, and upon checking the warnings it is realised that the line "constant maxFileLines = 200" is in fact a code line missing the @ symbol, and not a host command. Edit this line to be "@constant integer maxFileLines = 200". File>Save. The script is now [syntax] error free.

 




Using the Watch Variables tab

 
  1. Move to the Watch Variables tab by clicking on it in the Multi-function pane. See section 3.4.6 for an overview of the Watch Variables tab.
  2. Add watch variables FILENAME, LINECOUNT and FILELINE to the Watch Variables tab.
  3. Add breakpoints to the program at line 00024 and 00039. For information on how to add a breakpoint, see Section 3.2. Note that re-compilation will remove the breakpoint. Execute the script with the Run Action Button or Script>Run.
  4. In the dialog that appears, enter "C:\boot.ini" (for Windows NT - else some small ASCII text file). Execution will break at line 00024. The Watch Variables tab should appear as below.

Figure 4.7 - Watch Variables tab

Watch Variables Tab

  1. On line 00024 error.cmd will assign a line of the file being read to FILELINE. Hit the Continue Run Action Button or Script>Continue Run to see the assignment (error.cmd will loop back to 00024 and stop before updating FILELINE a second time). The Value field of FILELINE in the Watch Variables tab has changed to reflect the first line of the current file. In addition, LINECOUNT has been updated to show that error.cmd is currently on line one of the file.
  2. For this iteration, press the Step Action Button or Script>Step repeatedly and pinpoint the line where the variables FILELINE and LINECOUNT are updated. Viewing where updates take place in a script is a useful debugging option.
  3. Remove the break-point on line 00024 and hit the Continue Run Action Button or Script>Continue Run. Execution will now stop on line 00039. The program now has a filename stored in a String variable, and the file contents stored line by line in a String array.
  4. Another useful debugging feature is being able to change the values of variables at run-time. While execution is halted at line 00039, the file name and 2nd line of the file contents can be changed in memory before being displayed to screen. Begin by using the Watch Variables tabs right-click menu to modify the Value of FILENAME to "No, wait, I’m not displaying a file!!!".
  5. Now, we wish to modify the value of FILELINES. Begin by watching FILELINES as per Section 3.4.6.1. Now, using the right-click menu again, modify its value to "Nothing is as it seems!".
  6. Hit the Continue Run Action Button or Scripts>Continue Run to see the modified memory contents displayed to screen.



Using Interactive Run-time Error Control

 
  1. Edit the error.cmd script by declaring a integer on line 10 called test. Initialise it to any number, say 5. So type @integer test = 5. On line 11 add code to divide test by lineCount (already set to 0). Use @set test = test / lineCount.
  2. This code is syntactically correct, but it divides by 0. Run the code by using Script->Run or by using the Run action button.
  3. The user is prompted with a Runtime Error Dialog asking them if they wish to continue. Firstly, the user may choose Yes to continue. In this case, the code will continue to run the subsequent lines which prompt them to enter a filename. Secondly, the user may choose No and the script will halt on line 11 which caused the runtime error. The Runtime Error Dialog is shown below:


    Figure 4.8 - Runtime Error Dialog

    Runtime Error Dialog



Previous Section
Previous Section: Connecting to a Remote Host
Document HomeDocument Home
Next Section: Automated Script Execution
Next Section


This publication has been prepared and written by Telstra Corporation Limited (ACN 051 775 556), and is copyright. Other than for the purposes of and subject to the conditions prescribed under the Copyright Act, no part of it may in any form or by any means (electronic, mechanical, microcopying, photocopying, recording or otherwise) be reproduced, stored in a retrieval system or transmitted without prior written permission from the document controller. Product or company names are trademarks or registered trademarks of their respective holders.

Note for non-Telstra readers: The contents of this publication are subject to change without notice. All efforts have been made to ensure the accuracy of this publication. Notwithstanding, Telstra Corporation Limited does not assume responsibility for any errors nor for any consequences arising from any errors in this publication.