Author Topic: Looking for a Variable Clean up tool...  (Read 2584 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
Looking for a Variable Clean up tool...
« on: July 10, 2007, 01:02:30 PM »
With all these programs and what not and setting all these variables is there any tool that can reset them? I have noticed that if i name a variable the same as a variable that is set by a different program then the next program will crash and burn sometimes.


deegeecees

  • Guest
Re: Looking for a Variable Clean up tool...
« Reply #1 on: July 10, 2007, 01:42:37 PM »
Before I create a variables' name, I usually do a (atoms-family 0), and send it to ntepad, and do a search on the new variables name. If it's in the list, I choose another name. You could probably do this programatically as well.

SomeCallMeDave

  • Guest
Re: Looking for a Variable Clean up tool...
« Reply #2 on: July 10, 2007, 02:21:41 PM »
Take a look at the Developer Help where it discusses Local vs Global variables.

Using local variables may help you with your problem.


ronjonp

  • Needs a day job
  • Posts: 7531
Re: Looking for a Variable Clean up tool...
« Reply #3 on: July 10, 2007, 03:11:48 PM »
If you prefixed all your variables with something to make them different from the rest, you could use something like this to set them to nil:

Code: [Select]
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "COOLPREFIXHERE:*")
(set (read x) nil)
       )
     )
    (atoms-family 1)
  )

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

AVCAD

  • Guest
Re: Looking for a Variable Clean up tool...
« Reply #4 on: July 10, 2007, 04:38:20 PM »
If you prefixed all your variables with something to make them different from the rest, you could use something like this to set them to nil:

Code: [Select]
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "COOLPREFIXHERE:*")
(set (read x) nil)
       )
     )
    (atoms-family 1)
  )

Ron

I put this in my code

Code: [Select]
(defun set_var_nil()
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "symb_*")
(set (read x) nil)
       )
     )
    (atoms-family 1)
  )
  )

but it didn't work...did i do something wrong?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Looking for a Variable Clean up tool...
« Reply #5 on: July 10, 2007, 05:48:37 PM »
When I'm doing testing that needs temporary global variables I prefix them with unique characters and use (essentially) similar code to that posted by Ron. When I'm finished testing I remove the prefix (find and replace) and make the variables local.

Dave's recommendation ( use local variables ) should solve your problem.



 
......... but it didn't work...did i do something wrong?

You may have.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Looking for a Variable Clean up tool...
« Reply #6 on: July 10, 2007, 06:53:39 PM »
If you prefixed all your variables with something to make them different from the rest, you could use something like this to set them to nil:

Code: [Select]
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "COOLPREFIXHERE:*")
(set (read x) nil)
       )
     )
    (atoms-family 1)
  )

Ron

I put this in my code

Code: [Select]
(defun set_var_nil()
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "symb_*")
(set (read x) nil)
       )
     )
    (atoms-family 1)
  )
  )

but it didn't work...did i do something wrong?

You need to make the filter uppercase, or specify T with the strcase:

(defun set_var_nil()
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x T) "symb_*")
    (set (read x) nil)
       )
     )
    (atoms-family 1)
  )
  )

or

(defun set_var_nil()
  (mapcar
    '(lambda (x)
       (if (wcmatch (strcase x) "SYMB_*")
    (set (read x) nil)
       )
     )
    (atoms-family 1)
  )
  )

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC