PDA

View Full Version : Error Check Question


prose
2009-03-26, 06:12 PM
I have this simple routine I wrote which is included in our acad.lsp file.
It will load the individual users lisp routine.


(load(strcat "\\\\Flfile\\Fort\\Cad\\Acad Master Files\\Routines\\Lisp Files\\"(getvar"loginname")".lsp"))
(princ)


I works great, the issue is, I would like to write an error check in the code stating;
if lisp routine is not found show error message, if found load routine as normal.

Any ideas? Thanks in advance.

rkmcswain
2009-03-26, 06:24 PM
The (load) function can return a value if the load fails.

Something like this should work.




(if (not (load "myfunc" nil))
(alert "NOT FOUND!")
)

prose
2009-03-26, 06:37 PM
Okay, I tried it like this;

(if (not (load(strcat "\\\\Flfile\\Fort\\Cad\\Acad Master Files\\Routines\\Lisp Files\\"(getvar"loginname")".lsp") nil))
(alert "NOT FOUND!")
)
(PRINC)


It ends up loading it, then giving me the message anyway.
Any idea what I'm doing wrong?:?

rkmcswain
2009-03-26, 07:00 PM
Okay, I tried it like this;

(if (not (load(strcat "\\\\Flfile\\Fort\\Cad\\Acad Master Files\\Routines\\Lisp Files\\"(getvar"loginname")".lsp") nil))
(alert "NOT FOUND!")
)
(PRINC)


It ends up loading it, then giving me the message anyway.
Any idea what I'm doing wrong?:?

(load) should return a SYM if successful, and the value of the second argument if it fails...

Just for grins, try this, right out of the help file.




(if (eq 'STR (type (load "myfunc" "bad")))
(alert "NOT FOUND!")
)

prose
2009-03-26, 07:07 PM
This worked.


(if (eq 'STR (type (load (strcat "\\\\Flfile\\Fort\\Cad\\Acad Master Files\\Routines\\Lisp Files\\"(getvar"loginname")".lsp") "bad")))
(prompt "\nNOT FOUND!")
)
(princ)


Thanks for your help.