ActiveCompanionSet xtras for Macromedia Director
Every wrapper object created by VbScriptXtra can detect errors returned by wrapped objects. Internal VbScriptXtra errors (type casting problems etc) could happen too. Normally these errors could be trapped programmatically by checking object's last error status after any meaningful call to the object. See error handling support properties for more details. To simplify debugging process VbScriptXtra provides debugging mode.
Simple Debugging Mode
In simple debugging mode any wrapper object puts error information into Messages window whenever error occurred. Usually simple debugging mode is useful to detect whether script is executed well or there is a problem somewhere. Error messages usually come from wrapped objects but there is no information about the context where error occurred.
Advanced Debugging Mode
Advanced debugging mode allows you to catch error right in Debugger whenever error occurred. In this mode VbScriptXtra tries to call movie-level handler VbScriptXtra_DebugEvent( strMes, nCode ). If there is no such handler, the xtra behaves as in simple debugging mode. This handler may contain any Lingo statements. Furthermore, you can place a break point inside this handler and use Director's debugging capabilities to view the calling context, variables etc.
Sample movie-level handler for advanced debugging.
if the playerMode = "author" then
xtra("VbScriptXtra").Init( 2 )
on VbScriptXtra_DebugEvent strMes, nCode
put strMes -- Place the break point here
Debugging mode is kept separately for every VbScriptXtra wrapper object. Use DebugMode property to change the debugging mode of the particular object directly. Otherwise use xtra-level Init( nDebug ) method to set the default debugging mode for newly created wrappers. This method does not affect objects that already exist at the time of calling this method.
Using Put Command
Every wrapper object provides descriptive information about itself via put Lingo method. To see what the wrapper object contains simply put it in Messages window.
Vb = xtra("VbScriptXtra")
objDate = vb.CreateWrapper( #Date )
--"< VbScriptXtra, Date/Time, 09/03/2004 20:22:44 >"
objWord = vb.CreateObject("Word.Application")
--"< VbScriptXtra, _Application, 0x001FB29C, (1) >"
objBinary = vb.CreateWrapper( #Binary )
objBinary.String = "Test"
--"< VbScriptXtra, Binary, Size: 4 byte(s) >"
Using Debugger and Object Inspector
VbScriptXtra wrappers support viewing their contents via Director Debugger and Object Inspector.
Automation wrapper allows expanding its entry in Debugger to view properties of the wrapped Automation object. It is quite convenient although it has side effect that conflicts with debugging modes. When wrapper's entry in debugger is expanded Director internally calls all properties available to view in debugger. Wrapper object cannot distinguish whether it is called by debugger or by Lingo script. Therefore last error information kept by the wrapper object is erased with the status of the last method or property that was called by Director but not Lingo script. In advanced debugging mode the VbScriptXtra_DebugEvent movie level handler could be called while Director asks object for its property values. So take care with that.