XSIUtils.ExternalScriptDebugger

導入

v5.0

詳細

レジストリキー(HKEY_CURRENT_USER¥Software¥Microsoft¥Windows Script¥Settings¥JITDebug)のBoolean値を設定したり、戻したりします。レジストリキーは、Softimage 内でスクリプトエラーが発生したときに外部スクリプトデバッガを起動するかどうかを制御します。

スクリプトのデバッグには、Microsoft Script Debugger または Microsoft Visual Studio .Net Debugger などのデバッガが必要です。

スクリプトエラーが発生した時や VBScript、JScript が停止状態の時、デバッガ状態が実行されます。

デバッガの途中でスクリプトコードを編集することはできません。ただし、変数値をチェックしたり、行毎にコードを検証したり、変数値を再度検討することによって、スクリプトに関する問題点を解決することができます。

通常は、スクリプトをデバッグしたい時のみ外部デバッガを有効にし、普通に使用しているときは無効にしておくと便利です。デバッガを有効のままにしておくと、通常、Softimage によりエラーが発生し、スクリプトの実行を停止させることがあります。たとえば、モーダルプロパティページでキャンセルを押すと、Softimage により通常エラーが発生しますが、有効になっている場合はデバッガが起動します。

ヒント:Script Editor から外部デバッガを有効にすることができます(VBScript と JScript code)。編集ペインで右クリックし、[ツール]>[外部スクリプトデバッガを有効]をにします。

注:外部スクリプトデバッガは、Python スクリプト(独自のデバッガを持つ)、Linux、または Netview ベースのスクリプトコードには適用されません。グローバル設定になっているため、Internet Explorer でWebページを表示しているときに、"Just-In-Time Debugger"というメッセージが表示されることがあります。

1. JScript の例

/*
        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 の例

/*
        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 の例

'
'       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 の例

' 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 の例

#
#       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()