ajs Posted June 10, 2009 Posted June 10, 2009 I'm converting a lisp from Intellicad Common Lisp to Autocad AutoLisp In Intellicad I have two scripts that run at the end of the Lisp: Syntax: (Command "script" "C:\\Solid_Export\\MyScript1.scr") (Command "script" "C:\\Solid_Export\\MyScript2.scr") The reason I have these scripts instead of just using Lisp is that it allows the end user to enable small customizations without having to actually open up the Lisp. When I try to enter these two scripts into AutoLisp, the first script runs correctly but the second script will not run. Instead, I get this error message: "Can't reenter LISP." I'm making the assumption that AutoLisp closes when encountering a script. Can anyone tell me if there is a syntax to run a script from within AutoLisp? Thank you for any help AJS Quote
Lee Mac Posted June 10, 2009 Posted June 10, 2009 I'm converting a lisp from Intellicad Common Lisp to Autocad AutoLisp In Intellicad I have two scripts that run at the end of the Lisp: Syntax: (Command "script" "C:\\Solid_Export\\MyScript1.scr") (Command "script" "C:\\Solid_Export\\MyScript2.scr") The reason I have these scripts instead of just using Lisp is that it allows the end user to enable small customizations without having to actually open up the Lisp. When I try to enter these two scripts into AutoLisp, the first script runs correctly but the second script will not run. Instead, I get this error message: "Can't reenter LISP." I'm making the assumption that AutoLisp closes when encountering a script. Can anyone tell me if there is a syntax to run a script from within AutoLisp? Thank you for any help AJS As a quote from the ACAD help file on using the SCRIPT command: If the SCRIPT command is used with the command function, it should be the last function call in the AutoLISP routine. Hence, I doubt that you can execute LISP functions after the script command has executed. Quote
ajs Posted June 10, 2009 Author Posted June 10, 2009 Thank you for replying. I did go into the script section of the help file but I must not have been thorough as I did not notice the excerpt you showed. Boy, the script issue is bad news for me; the Intellicad Lisp(s) I mentioned are permeated with scripts scattered throughout the Lisps. For this particular situation wherein the scripts are at the end of the lisp, what I'm going to try next is to see if I can append the scripts not at the end of the Lisp but following the lisp as commands in the menu. AJS Quote
Lee Mac Posted June 10, 2009 Posted June 10, 2009 Thank you for replying. I did go into the script section of the help file but I must not have been thorough as I did not notice the excerpt you showed. Boy, the script issue is bad news for me; the Intellicad Lisp(s) I mentioned are permeated with scripts scattered throughout the Lisps. For this particular situation wherein the scripts are at the end of the lisp, what I'm going to try next is to see if I can append the scripts not at the end of the Lisp but following the lisp as commands in the menu. AJS I must admit, I wouldn't like to be in your situation right now... I absolutely hate mixing scripts with LISP - always ends in tears. Quote
ajs Posted June 10, 2009 Author Posted June 10, 2009 My idea for appending the scripts has worked. Almost all the lisps that I use are menu driven so I was able to insert the first script at the end of the original lisp and then insert the second script into another lisp which follows the first Lisp: (load "C:/Solid_Export/FIX_LAYEX.lsp");FIX_LAYEX;(load "C:/Solid_Export/SCR_2.lsp");SCR_2 This is somewhat good news because what this means is that as a "stop-gap" measure if I just have a lisp with a couple of scripts in it, I can (thoeretically): 1) run the script (which will end the Lisp) 2) If additional sequential scripts; reload the other scripts 1 lisp at a time 3)Reload the original lisp Not the most elegant solution obviously but at least something I can do to keep things running during the transfer Thanks again Quote
Lee Mac Posted June 10, 2009 Posted June 10, 2009 I'm glad you got it sorted, I'm just sorry I could not be of more use Quote
Freerefill Posted June 10, 2009 Posted June 10, 2009 Think of it this way... A computer program is process linearly, that is to say, one bit at a time. It won't go to the next until it's done with the one it's on. This is true for LISPs; once started, they don't stop unless paused, error'ed, etc. Nor do scripts. Running a script in a LISP means that the LISP continues -as the script is running-. Which is why, if you try to run two scripts in a LISP, they'll step on each others toes, and blam, error. Even the theoretical stop-gaps are only theoretical, I myself have tried a few. The only way to really do it is to put it in your script to run the next LISP, which puts you on a really complicated daisy chain. However, there may be a solution, that of running LISP code in your script. Suppose, for instance: ; LISP (defun c:hi() ; Do something ; Load and run Script (while (not check) ; Do nothing ) ; Do something else ) ; Script command do something (setq check 1) You can see that, in the script, it will allow the LISP to continue, but the LISP will not and cannot continue until the script has finished doing its thing, thus setting "check" to non-nil. This does mean you need to write your scrips and LISPs to be coordinated (and anyway, this is all theoretical, I haven't tried it, though you can set variables in scripts) but it's a possible option. Give it a shot, I'm curious too. :3 Quote
ajs Posted June 10, 2009 Author Posted June 10, 2009 Thank you for responding I have to leave my desk right now but when I return, I'm going to take you up on your idea As a theory question, (Not an advocacy position; Autolisp is far more robust, obviously ) I wonder why Intellicad running Common Lisp 1.0 has no problems with multiple command line scripts as described above. The reason I bring it up is that there must be some kind of process in the background that allows this and if so, logic would dictate that it should be possible in any kind of Lisp including AutoLisp. or is this wishful thinking... 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.