QAID # 11581 Published
Question / Problem:
How can I debug a KTM Validation Script?
Answer / Solution:
- From the menu in the KTM Validation module:
- Select Options ¦ Settings... ¦ Miscellaneous.
- Check (set) the "Allow script debugging" option.
Note: When a scripting error occurs, it will open the Script Editor on the machine where the error occurs, revealing the source code. It is not recommended that this remain enabled in a production environment, once the error is resolved.
- The line of code that needs to be viewed first will be highlighted in red in the Script Editor Windows.
- On the Script Editor Toolbar, there will be tools available such as:
- “Browse Object”
- “Toggle Break”
- “Evaluate Expression”
- “Show Current Statement”
- “Step Into” (Used for debugging)
- “Step Over” (Used for debugging)
- “Step Out” (Used for debugging)
- “Edit UserDialog”
- “Edit Module Properties”
- The additional debugging options, listed below, can be accessed by right-clicking anywhere within the Script Editor and navigating to the “Debugging” menu options.
- All the debugging options and their functions:
Step Into Execute the current line. If the current line is a subroutine or function call, stop on the first line of that subroutine or function. (If the macro is not active, start it.)
Hot Key: F8
Step Over Execute to the next line. If the current line is a subroutine or function call, execute that subroutine of function completely.
Hot Key: Shift+F8
Step Out Step out of the current subroutine or function call. Hot Key: Ctrl+F8 Step to Cursor Execute until the line the cursor is on is the current line. (If the macro is not active, start it.)
Hot Key: F7
Toggle Break Toggle the break point on the current line. Hot Key: F9 Clear All Breaks Clear all break points. Hot Key: Shift+Ctrl+F9 Quick Watch Show the value of the expression under of the cursor in the immediate window. Hot Key: Shift+F9 Add Watch Add the expression under of the cursor in the watch window. Hot Key: Ctrl+F9 Browse Show the methods of the expression under of the cursor. Set Next Set the next statement to be executed. Only statements in the current subroutine/function can be selected. Show Next Show the next statement to be executed.
Using the debugging tools in collaboration with the Script documentation will assist in debugging and troubleshooting KTM Validation Script issues.
- One other option is to add a Message Box for particular events firing to view values/information existing at certain points during the code.
MsgBox "This is my Message Box"