TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: MeasureUp on March 26, 2013, 12:43:46 AM
-
It makes me frustrated.
Your helps are much appreciated.
If I enter this on the command line:
(findfile "E:\\Test.vlx")
it returns:
"E:\\Test.vlx"
Then I load this file by entering this on the command line"
(load "E:\\Test.vlx")
it returns:
nil
It tells me that the file is not loaded.
-
From the help:
Return Values
Unspecified, if successful. If load fails, it returns the value of onfailure; if onfailure is not defined, failure results in an error message.
Have you considered that Nil is simply being returned as you do not currently have an ending (princ) in the last routine being loaded? Do your commands/routines work?
What happens when you include the onFailure parameter:
(load "E:\\Test.vlx" (progn (prompt "\n** Load failed ** ") (princ)))
-
It returns:
** Load failed ** nil
-
It returns:
** Load failed ** nil
Just wanted to be certain; time to debug your source-code.
-
Check the definition of (load...), specifically what the return value is: Unspecified if successful. If it fails, it returns the [onfailure] argument.
So it appears to be working properly.
-
It makes me frustrated.
Your helps are much appreciated.
If I enter this on the command line:
(findfile "E:\\Test.vlx")
it returns:
"E:\\Test.vlx"
Then I load this file by entering this on the command line"
(load "E:\\Test.vlx")
it returns:
nil
It tells me that the file is not loaded.
if you know the path of the file, why tell to findfile?
(load (findfile "test.lsp"))
provided you have the file path in the acad search path.
if you know the file path, there is no need to find the file just have it load from the path
-
^^ IMO .. it's good to check that the file can be found before trying to load it...
(if (findfile "E:\\Test.vlx") (load "E:\\Test.vlx"))
-
^^ IMO .. it's good to check that the file can be found before trying to load it...
(if (findfile "E:\\Test.vlx") (load "E:\\Test.vlx"))
+1, especially if the [onfailure] argument is omitted - the (load ...) call will error out in that case. So either (findfile...) and (load filename), or no (findfile...) and (load filename "Hey I failed").
-
^^ IMO .. it's good to check that the file can be found before trying to load it...
(if (findfile "E:\\Test.vlx") (load "E:\\Test.vlx"))
Yes. This is what I am doing.
And thanks to everyone.
Problem solved as I found there is a logical error on the "IF" condition in my "FINDFILE" code.