bitslapped Posted December 18, 2011 Posted December 18, 2011 I'm sure this is really simple but I'm having problems. I want to run 'lockallvp.vlx' every time i open a file. I am currently using acaddoc as follows: (load "lockallvp.vlx") lockallvp The plugin loads but does not run. Thanks for your help Aaron Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 Use: (if (load "lockallvp.vlx" nil) (c:lockallvp) (princ "\nFailed to Load lockallvp.vlx") ) Or, with slightly more error trapping: (if (and (load "lockallvp.vlx" nil) c:lockallvp) (c:lockallvp) (princ "\nFailed to Load lockallvp.vlx") ) Welcome to the forum Quote
bitslapped Posted December 19, 2011 Author Posted December 19, 2011 Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test? e.g. (if (and (load "lockallvp.vlx" nil) c:lockallvp) (princ "\nlockallvp.vlx loaded and successfully executed") (princ "\nFailed to Load lockallvp.vlx") ) Quote
BlackBox Posted December 19, 2011 Posted December 19, 2011 Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test?e.g. (if (and (load "lockallvp.vlx" nil) c:lockallvp) (princ "\nlockallvp.vlx loaded and successfully executed") (princ "\nFailed to Load lockallvp.vlx") ) c:lockallvp invoked via LISP will not execute without the necessary parenthesis, like so: (c:lockallvp). If the function is being executed at load, that is because the author of the VLX add the above mentioned call at the end of their function definition. Another simple example: (defun c:HelloWorld () ; <-- Define function (prompt "\nHello World! ") (princ)) (c:HelloWorld ) ; <-- Autorun function Quote
SLW210 Posted December 20, 2011 Posted December 20, 2011 Also, please remember to use . [color=white].........................................[/color] Quote
Lee Mac Posted December 20, 2011 Posted December 20, 2011 Thanks Lee. it appears your second example runs the function more than once. Is there are reason the 'if' statement wouldn't inherently perform the function during the test?e.g. (if (and (load "lockallvp.vlx" nil) c:lockallvp) (princ "\nlockallvp.vlx loaded and successfully executed") (princ "\nFailed to Load lockallvp.vlx") ) Perhaps that author included a call to the function within the vlx application, as Renderman suggests. As for: (if c:lockallvp (do_something) (else_do_something) ) The function c:lockallvp is not being evaluated, I am simply testing the symbol 'c:lockallvp' to see whether a functional value has been bound to it; i.e. whether the symbol evaluates to something non-nil. As an example: _$ (defun c:LeeMac ( ) (princ "\nThis is a function.")) C:LEEMAC _$ _$ c:LeeMac #<USUBR @1755cb7c C:LEEMAC> ;; <--- Value of symbol 'c:LeeMac' (pointer to c:LeeMac Function Definition) Quote
BlackBox Posted December 20, 2011 Posted December 20, 2011 Lee, I believe this is the sample the OP is suggesting invokes the c:LockAllVp twice: (if (and ([color=blue]load "lockallvp.vlx" nil[/color]) c:lockallvp) ([color=blue]c:lockallvp[/color]) (princ "\nFailed to Load lockallvp.vlx") ) ** Edit - Again, presuming that the VLX includes a call at load. Quote
Lee Mac Posted December 20, 2011 Posted December 20, 2011 I thought the OP was confused as to why 'c:lockallvp' appeared in the AND statement, so provided a brief explanation - as you rightly suggest, my guess is that the lockallvp command runs when loaded. Quote
bitslapped Posted December 21, 2011 Author Posted December 21, 2011 Thanks gents that was all incredibly informative. Lee is right, I assumed the mention of lockallvp in the 'and' statement was running the function, but apparently it is just checking for the definition? Quote
BlackBox Posted December 21, 2011 Posted December 21, 2011 Thanks gents that was all incredibly informative.Lee is right, I assumed the mention of lockallvp in the 'and' statement was running the function, but apparently it is just checking for the definition? You are correct; more specifically when the AND statement passes (non-nil), the THEN portion of the IF statement is what invokes the command a second time (the LOAD being the first). Quote
bitslapped Posted December 21, 2011 Author Posted December 21, 2011 Thanks RenderMan I understand the structure. It is sad what time and an unrelated degree can do to my soft. eng. undergrad., particularly when I was doing ai in lisp. Tisk. Really appreciate the solid feedback. Hope I can give back some time. Quote
SLW210 Posted December 21, 2011 Posted December 21, 2011 Thanks RenderMan I understand the structure.It is sad what time and an unrelated degree can do to my soft. eng. undergrad., particularly when I was doing ai in lisp. Tisk. Really appreciate the solid feedback. Hope I can give back some time. Now that you mention it....using CODE TAGS would be a big help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.