permanence of variables' value after running a lisp

permanence of variables' value after running a lisp

Anonymous
Not applicable
1,332 Views
7 Replies
Message 1 of 8

permanence of variables' value after running a lisp

Anonymous
Not applicable

Hello, I'm trying to write a lisp to draw some circles inside of a polygon, given some user input. 

The code doesn't work so far and, especially after I built a while-loop in. The code runs as long as the loop-check returns nil and then sops (as it should) but the result on the screen isn't what I was looking for. 

Now, I would like to know which value each variable has taken,  in order to better find the error, but after running (almost) all variables are "nil" or in some cases, they have one value I set as a test before running the lisp. Is there a way to make the program "remember" all its variables' values? 

I hope it makes sense.. 

I declare all my variables as global variables with setq. 

 

PS: I attached the code, in case somebody wants to have a look. The while loop causing the problem is starting at line 166 (now as a comment). 

0 Likes
Accepted solutions (1)
1,333 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... Is there a way to make the program "remember" all its variables' values? .... 



What I typically do for that purpose is to temporarily comment them out as localized variables, and set them all to nil at the beginning of the routine:

 

(defun c:CAV (/ *error*);;;; a_app c_doc c_spc sv_lst sv_vals sobj dst1 dst2 bobj spt vpt nobj ept len rdst ipt cobj)

(setq a_app nil c_doc nil c_spc nil sv_lst nil sv_vals nil sobj nil dst1 nil dst2 nil bobj nil spt nil vpt nil nobj nil ept nil len nil rdst nil ipt nil cobj nil)

 

Then after you run the routine, you can check what value [if any] is in any of them by typing them at the Command line with a preceding exclamation point:

!dst1

but when you run the command again, they will all be wiped out in the same way that localizing them makes them start from nothing each time.

 

Once everything is working, remove the commenting-out part to restore them to being localized, and remove the entire (setq)-to-nil part

Kent Cooper, AIA
0 Likes
Message 3 of 8

devitg
Advisor
Advisor

hi @Anonymous , 

For better understanding, and maybe get further help, please upload such sample.dwg

 

Doing this  

 

deactivate the echoing of prompts and input while the routin runs

while programing , is as to drive  a car in a dark night , foggy time , and your eyes closed.  

Up you solve the problem let de echomode to 1 

 Also do not use defun error , as it will retrieve all to the start. 

and do your variables global , so you can retrieve it's value. 

If need, you can make , temporary the variable to nil .

 

 

 

0 Likes
Message 4 of 8

ВeekeeCZ
Consultant
Consultant

@Anonymous

don't you think that this learning curve you're undertaking is too steep for you?

 

I can see that the code is based on @dlanorh 's routine full of vla, blah, vlax, mapcars... and lambd.. ohh, no anonymous functions this time. Seems to mee a rather advanced routine for the beginner to understand. I would really like to see some nice commands that are quite easier to understand, easy to trace, nicely named variables... and maybe some black-boxes from Lee that you know what to put in them and what you get from them.

 

I know you got what you got... and trying your best to understand.......... but the routine should be simpler.

0 Likes
Message 5 of 8

Anonymous
Not applicable

@ВeekeeCZ, yes I agree. I do that for my job but, since nobody asked me to do that, I have to squeeze it between all my other tasks. So I have been a bit impatient and just did some tutorials as a start.

But yes I know it's too much for my level. 

0 Likes
Message 6 of 8

hak_vz
Advisor
Advisor

Use the method described by @Kent1Cooper this is the best way to track variable values.

In every function localize all internal variables.  Check that those functions work independently and, if needed, do they return or set value correctly.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 7 of 8

chaitanya.chikkala
Enthusiast
Enthusiast

Hi,

If I understand your question correctly, I would do as below :

 

In order to view all the values taken by a variable during each iteration or at each step within program, I would construct a list of values taken by that variable at each iteration or at each step as below :

(SETQ LIST_TO_CHECK (CONS VARIABLE_TO_CHECK LIST_TO_CHECK))

 Then view the list in Visual Lisp Console

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

Very quick glance look at (defun :pospt happy to be told its ok. Did you run in VLIDE and look in the debug for the Last break source