カスタム *error* ハンドラ内での AutoLISP スタックの変数の使用を示すエラー処理関数。
サポートされているプラットフォーム: Windows および Mac OS
(*push-error-using-stack*)
引数はありません。
タイプ: T
値 T が返されます。
カスタム *error* ハンドラから、エラーが発生した関数内で定義されているスタック上のローカル AutoLISP 変数にアクセスできます。*push-error-using-stack* 関数に対する呼び出しは、*push-error-using-command* に対する以前の呼び出しより優先されます。
*push-error-using-command* または *push-error-using-stack* が呼び出されていない場合、AutoLISP は既定で *push-error-using-stack* が呼び出された場合と同様に動作します。
次に、*push-error-using-stack* 関数の使用例を示します。
(setq var1 "Global1" ; Set some global variables
var2 "Global2")
(defun mySub_err (err_msg)
(if (/= err_msg "Function cancelled")
(progn
(prompt (strcat "\nError: " err_msg))
(prompt (strcat "\nLocalSub1: " var1))
(prompt (strcat "\nLocalSub2: " var2))
(terpri)
)
)
(command-s "._undo" "_e")
(command-s "._U")
(setq *error* olderr)
(princ)
)
(defun subUtil (val / olderr var1 var2)
(*push-error-using-stack*) ; Indicates if the custom error handler has access to local
; variables defined in his function
(setq olderr *error*
*error* mySub_err)
(command "._undo" "_group") ; The following will not be executed in this sample, but is good
; framework for setting up your own error handlers
(setq var1 "Sub1" ; Set some local variables
var2 "Sub2")
;; Perform your tasks here
(strcat "Foo" val)
(command "._undo" "_e")
(setq *error* olderr) ; Restore old *error* handler
(*pop-error-mode*) ; End the use of *push-error-using-command*
)
(defun my_err (err_msg)
(if (/= err_msg "Function cancelled")
(progn
(prompt (strcat "\nError: " err_msg))
(prompt (strcat "\nLocal1: " var1))
(prompt (strcat "\nLocal2: " var2))
(terpri)
)
)
(command "._undo" "_e")
(command "._U")
(setq *error* olderr)
(princ)
)
(defun myUtil (val / var1 var2)
(setq olderr *error*
*error* my_err)
(*push-error-using-command*) ; Indicate use of Command function instead of Command-s
; in the custom error handler
(setq var1 "Local1" ; Set some local variables
var2 "Local2")
(command "._undo" "_group") ; The following will not be executed in this sample, but is good
; framework for setting up your own error handlers
(subUtil val) ; Call to a custom function that uses *push-error-using-stack*
(/ 1 0) ; Call a function with incorrect values to trigger the custom error handler
; Remove when setting up your code
;; Perform your tasks here
(command "._undo" "_e")
(setq *error* olderr) ; Restore old *error* handler
(*pop-error-mode*) ; End the use of *push-error-using-command*
)
サンプル コードをロードした後、コマンド プロンプトに対して (myutil 1) と入力してネストした関数のエラー ハンドラを入力し、(myutil "String") と入力してメイン関数のエラー ハンドラをテストします。