X11start Posted May 28, 2021 Posted May 28, 2021 Why if I load and launch one of my lisp, then I load another ... the previous one has malfunctions? Ex. Asks me questions that are part of the 2nd lisp loaded? I thought that it was the fact that I use the same variables and that these were not "closed" inside the lisp (or placed at "nil" before exit). But then I found that this happens even when my lisp is "well done"! I have never asked myself the problem and I have always solved it by loading immediately before using the lisp that interests me Quote
tombu Posted May 28, 2021 Posted May 28, 2021 One may be setting a system or environmental variable that affects how the other works. Hard to tell without seeing both codes. It's best to use error handling to make sure your routines reset any changes even when you use Esc to get out of them. Do either of them use USER* system variables, global variables or reactors? Quote
mhupp Posted May 28, 2021 Posted May 28, 2021 You probably have an open paren or missing close in one of your lisp that is causing the error. That will sometimes make two lisp interact with each other. Quote
X11start Posted May 28, 2021 Author Posted May 28, 2021 35 minutes ago, tombu said: Uno potrebbe impostare un sistema o una variabile ambientale che influisce sul funzionamento dell'altro. Difficile da dire senza vedere entrambi i codici. È meglio usare la gestione degli errori per assicurarti che le tue routine ripristinino le modifiche anche quando usi Esc per uscirne. Entrambe utilizzano variabili di sistema USER *, variabili globali o reattori? I don't use reactors or USERS variables. Maybe it's just a matter of variables "normal" reused and not reported to NIL! I don't think you can have non-closed brackets .... and a working lisp. However, it is easily circumvented by doing LOAD once. Thanks for the replies. Quote
X11start Posted May 28, 2021 Author Posted May 28, 2021 Example: - I open a new drawing, I load "Copiatxt" (it is used to copy a text from another), - I execute the command and I make 2 texts equal. - Load of "Freccia" (used to create an arrow made with a polyline), I also execute this command. - Finally I launch (without loading!) in the command line "Copiatxt" .... it asks me for the vertex of the arrow! COPIATXT.LSP FRECCIA.LSP Quote
mhupp Posted May 28, 2021 Posted May 28, 2021 (edited) Your using a lot of global variables maybe their is a shared few between the two lisp? its good house keeping to clear those out after the command is run. (defun indati () to (defun indati (/ modes stiletxt entl entbl ent entb lis lisl txt nuo lis2) nm see your doing that in COPIATXT in COPIATXT you have a function called indati in FreeCCIA you have a function called INDATI change the names of them and it will clear up your problem when the function is called in FreeCCIA.lsp its going to the first time it sees that function and its in COPIATXT.lsp because it was loaded first Edited May 28, 2021 by mhupp Quote
X11start Posted May 28, 2021 Author Posted May 28, 2021 (edited) Se scrivo! INDATI dalla riga di comando ottengo: # <SUBR @ 000000002EB9AC48 INDATI> quindi forse potrei scrivere: (setq INDATI nil) alla fine di ogni lisp ... forse risolve il problema.... No i tried: it kill both lisp files! Edited May 28, 2021 by X11start Quote
mhupp Posted May 28, 2021 Posted May 28, 2021 (edited) it needs to be named different because its going to go where it see it first and the lisp You load first that's where its going to go. in COPIATXT name the function INDATI-C in FreeCCIA name the function INDATI-F When you load lisp they are essentially in one file and it reads top down. your tying to get to the 2nd INDATI function but it will always stop at the first one if they are named the same. Edited May 28, 2021 by mhupp Quote
X11start Posted May 28, 2021 Author Posted May 28, 2021 ALL my lisp have "INDATI"! Well now I know what the problem is! Thank you very much Mhup Quote
Roy_043 Posted May 28, 2021 Posted May 28, 2021 (edited) 38 minutes ago, mhupp said: its going to go where it see it first and the lisp You load first that's where its going to go. This is not correct. Functions can be redefined by (re)loading Lisp files. So it is the function definition from the Lisp file that was loaded last that will be used. Edited May 28, 2021 by Roy_043 1 Quote
mhupp Posted May 28, 2021 Posted May 28, 2021 Oops got it backwards. just know its not good to have multiple functions that do different things named the same. Last in First out! Got it. Quote
X11start Posted May 28, 2021 Author Posted May 28, 2021 (edited) In all my lisp "INDATI" is the routine that has the task of requesting all the data and then sending them to the various processing ... maybe I should simply move this task to the main routine: "DEFUN C : ..." which obviously has different names for each lisp. thank you all Edited May 28, 2021 by X11start Quote
tombu Posted May 28, 2021 Posted May 28, 2021 Listen to mhupp and update all your code to use local variables! Using localized variables for subfunctions as well would avoid even more issues. Instead of changing and having to restore *error* Error handler simply add *error* as a local variable then define *error* inside your routine and it restores itself when you exit the routine. Had you localized INDATI in each routine you wouldn't have had issues with it either. Quote
BIGAL Posted May 28, 2021 Posted May 28, 2021 This may cause some problems using extended characters. Just a comment. ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» The 2 indati are very different also noted only runs once so a defun is not really needed as you suggested put in main code. Quote
X11start Posted May 29, 2021 Author Posted May 29, 2021 thanks everyone for the tips. I apologize if I don't write well in English: I'm much better with Italian! Quote
BIGAL Posted May 29, 2021 Posted May 29, 2021 Another suggestion (setq ent (entsel "\nClicca sul testo da modificare (Invio=Fine) : ")) 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.