TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on February 05, 2019, 02:52:11 PM
-
In the startup file I load all of the lisp scripts one by one.
(load "abc")
(load "123")
(load "etc.....")
if one of those lisp files do not load, I wish to continue onto the next line of code or continue loading the next lisp file. Is this possible?
-
-
OR
(load "123" "File load '123' failed ... ")
-
Thanks! I didn't know "LOAD" can take more than one argument.
-
OR
(load "123" "File load '123' failed ... ")
Unfortunately such messages would not be printed to the command-line unless the load expression were the last in the sequence of evaluation...
In the past I've considered using something like:
But this can cause issues if the AutoLISP file 123 returns an expression on loading that causes eval to either error or perform an undesired operation on load.
An alternative might be:
(if (= 'some
-obscure
-symbol
(load "abc" 'some
-obscure
-symbol
)) (princ "\nabc failed to load.") )
With the symbol obscure enough to avoid the possibility of causing a false-negative since one could not determine the return value of the file to be loaded ahead of time.
-
Say if one of my scripts has a bug.
123.lsp contains a malformed list.
error: malformed list on input
(load "123" "Failed")
will break the start up file.
What could I do to continue loading the next script?
OR
(load "123" "File load '123' failed ... ")
Unfortunately such messages would not be printed to the command-line unless the load expression were the last in the sequence of evaluation...
In the past I've considered using something like:
But this can cause issues if the AutoLISP file 123 returns an expression on loading that causes eval to either error or perform an undesired operation on load.
An alternative might be:
(if (= 'some
-obscure
-symbol
(load "abc" 'some
-obscure
-symbol
)) (princ "\nabc failed to load.") )
With the symbol obscure enough to avoid the possibility of causing a false-negative since one could not determine the return value of the file to be loaded ahead of time.
-
Sledgehammer approach:
-
if one of my scripts has a bug.
123.lsp contains a malformed list.
error: malformed list on input
(load "123" "Failed")
will break the start up file.
What could I do to continue loading the next script?
Fix 123.lsp. :P
Kidding aside, note that you can catch (and report) error messages captured by vl-catch-all-apply whilst continuing on with execution (if that's desirable). Read up on vl-catch-all-apply, vl-catch-all-error-p and vl-catch-all-error-msg functions (failing latter spoon feeding).
-
You know what, you are right. I have to make sure the code is stable and ready to use. What happened was, I left for vacation and there was some code I worked on that had an extra parenthesis. Which prevented the startup file from executing every line.
if one of my scripts has a bug.
123.lsp contains a malformed list.
error: malformed list on input
(load "123" "Failed")
will break the start up file.
What could I do to continue loading the next script?
Fix 123.lsp. :P
Kidding aside, note that you can catch (and report) error messages captured by vl-catch-all-apply whilst continuing on with execution (if that's desirable). Read up on vl-catch-all-apply, vl-catch-all-error-p and vl-catch-all-error-msg functions (failing latter spoon feeding).