XSIUtils.ExternalScriptDebugger

Introduced

v5.0

Description

Sets or returns the Boolean value on the registry key (HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings\JITDebug) that controls whether the external script debugger starts when a script error occurs in Softimage.

Script debugging requires a debugger such as Microsoft Script Debugger or the Microsoft Visual Studio .Net debugger.

The debugger starts when a script error occurs, or when a VBScript stop statement or JScript debugger statement is executed.

You cannot edit your scripting code in the debugger, but you can often solve tough scripting problems by checking variable values and stepping through code line by line and viewing variable values.

Typically, it is more convenient to enable the external debugger only when you want to debug your scripts, and to disable it during normal use. If you leave the debugger enabled, errors that are normally handled by Softimage may stop execution of your script. For example, clicking Cancel on a modal property page can raise an error that is normally handled by Softimage, but which will start the debugger if it is enabled.

Tip: You can enable the external debugger from the script editor (for VBScript and JScript code). In the editing pane, right-click and then click Tools > Enable External Debugger.

Note: ExternalScriptDebugger does not apply to Python scripts (which have their own debugger), Linux, or Netview-based script code. It is a global setting, so it may also cause "Just-In-Time Debugger" messages to appear when viewing Web pages in Internet Explorer.

C# Syntax

// get accessor

Boolean rtn = XSIUtils.ExternalScriptDebugger;

// set accessor

XSIUtils.ExternalScriptDebugger = Boolean;

Examples

1. JScript Example

/*

	This script demonstrates how XSIUtils.EnableScriptDebugger works when 

	a simple runtime error occurs.

*/

XSIUtils.ExternalScriptDebugger = true ;

// Runtime error - calling a function that doesn't exist

// will open the debugger

BogusFunction() ;

2. JScript Example

/*

	This script demonstrates how XSIUtils.EnableScriptDebugger works with 

	exception handling.

*/

XSIUtils.ExternalScriptDebugger = true ;

// Try/catch is great for robust code,

// but because it handles script errors it

// can be harder to debug

try {

	BogusFunction() ;

} catch(e) {

	Application.LogMessage( "Caught error before debugger sees it" ) ;

}

// If you want to find out where inside a try/catch

// the error actually happens, you can either temporarily

// comment out the try/catch, or step through the

// code line by line by adding a temporary call

// to "debugger"

try {

	debugger ;

	BogusFunction() ;

} catch(e) {

	Application.LogMessage( "Code jumps here, but you are already in debugger" ) ;

}

3. VBScript Example

'

' 	This script demonstrates how the XSIUtils.EnableScripDebugger works with 

'	a simple runtime error.

'

option explicit

XSIUtils.ExternalScriptDebugger = true

' Runtime error - uninitialized variable

' starts the script debugger

' (the error is caught because option explicit is enabled)

x = 45

4. VBScript Example

' Demonstration of how "on error resume next"

' interfers with the script debugger

'

' 	This script demonstrates how "on error resume next" interferes with the 

'	XSIUtils.EnableScriptDebugger.

'

option explicit

XSIUtils.ExternalScriptDebugger = true

' This On Error statement means that VBscript 

' ignores the undefined variable name, even

' though Option Explicit is on

on error resume next

x = 45

' The error info is stored in the "err"

' global object

Application.LogMessage err.description

' To debug this sort of code, try temporarily

' commenting out all "On Error Resume Next" statements, 

' or set a break point (with the "stop" keyword)

' and step line by line through the code

stop 

x = 45

5. Python Example

#

#	This script demonstrates how Python ignores the ExternalScriptDebugger

#

XSIUtils.ExternalScriptDebugger = 1

# So if you uncomment this line it 

# will just log an error inside Softimage

#Foobar()

# However you can open a debugger like this

import pywin.debugger

pywin.debugger.brk()

# And then step to reach this error within

# the debugger

Foobar()