Scripting - Debugging

(Go back to Scripting )

An essential part of writing any computer code is debugging it to ensure it runs as you intended. Here are some tips:

Use "Check Syntax"

The "Check Syntax" button will help you find errors without having to run the script. The line and column of the error is displayed.

Read error messages

When a script cannot execute correctly an error number and description is displayed. Along with the line and column of the error, you can look in your code and attempt to find the problem. You'll also see a string saying "Occured while ...", to help you find what piece of code is causing the error.

Comment your code

Lines starting with a quote (') are comments. Use them to clarify what your code is trying to accomplish – they will greatly help you if you come back to a piece of code you haven't touched in a while.

Use output at important steps

While debugging, it can be useful to know the value of some variables. For example, you might use a msgbox call to let you know how your code is proceeding. Remove or comment out any such debugging output once your code is working correctly.

Be careful about variable types

VBScript only allows the variant data type whereas some functions in the creature object for example require a specific type. If you get a type mismatch error, try using extra parentheses to force a conversion. For example:

Cr.FunctionName (Variable1), (Variable2), (Variable3)

Documentation for DM Genie and Player Genie, page Script_Debug. Copyright © Mad Scientist Studios, 2006.
Help Contents   |   DM Genie home page
Click here if you cannot see the table of contents on the left