VbScriptXtra v1 for Macromedia Director
Debugging your scripts using VbScriptXtra
Every VbScriptXtra wrapper instance has internal last error flag and error description. The last error flag is cleared before any access to the Automation object. If property access or method call failed or another error happened, this flag is raised. So you may detect whether last call completed successfully. Use object.Failed or object.Succeeded properties to check whether the last call was successful. If an error happened you may see its description using object.lastError property and see its code using LastErrorCode property.
Two types of errors might occur with VbScriptXtra depending who detects error condition either VbScriptXtra or wrapped COM Automation object. For example type casting routine of VbScriptXtra might return a error in case it cannot typecast Lingo value into COM Automation value. This is a VbScriptXtra-level error. LastErrorCode returns a value from the list below in this case.
The other type of errors occures inside COM library or inside a wrapped object. In this case LastErrorCode returns the value provided by COM library or by wrapped object.
If the last call was successful, then LastErrorCode returns 0.
VbScriptXtra's internal error codes:
1021 - "Cannot convert COM value to Lingo value."
1022 - "Cannot convert Lingo value to COM value."
1026 - "Cannot complete request. The remote application rejected the call. Probably it is busy."
Also you may adjust VbScriptXtra wrapper objects to output its lastError directly to the Message window every time error happens. Set object.DebugMode to true (1) to do this. By default, VbScriptXtra wrappers created by CreateObject call inherit the xtra's default value for debugMode. You may change this default with Init xtra-level method.
Note: While you are just investigating automation capabilities it is better to set Debug Mode by default, to ensure you always know if something goes wrong. It might be important while using cascading properties, since every property returning Automation Object will be wrapped by a new instance of VbScriptXtra wrapper, which has its own error flag and error description. So, you may skip useful error description from wrappers created on the fly, if you do not set Debug Mode.
Starting from version 22.214.171.124 VbScriptXtra supports advanced debugging mode. Activate it by using xtra("VbScriptXtra").Init(2) or set obj.DebugMode to 2. In this mode whenever error occurs, xtra calls movie level method VbScriptXtra_DebugEvent errMes, errCode. Place a break point inside your implementation of this method and you will always know when and where error happened, including the calling context and other debugging features of Director.