Author Topic: read only variables?  (Read 1914 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
read only variables?
« on: May 29, 2008, 02:40:30 PM »
Does anyone know of a way to determine if a variable is read-only?
Ex. Getvar would give you the value of a say viewtwist, but setvar of the same variable would create an error.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: read only variables?
« Reply #1 on: May 29, 2008, 03:05:20 PM »
I don't think so, but you can trap them in lisp
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
Re: read only variables?
« Reply #2 on: May 29, 2008, 03:12:03 PM »
Can you trap them in an if statement to just bypass them if they're in a list being processed with mapcar? How?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: read only variables?
« Reply #3 on: May 29, 2008, 03:19:49 PM »
You wouldn't be able to trap the error in an if statement
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

ronjonp

  • Needs a day job
  • Posts: 7529
Re: read only variables?
« Reply #4 on: May 29, 2008, 03:56:35 PM »
something like this?

Code: [Select]
  (foreach x '((acadlspasdoc . 1)
       (angdir . 0)
       (apbox . 1)
       (aperture . 8)
       (attdia . 1)
       (attmode . 1)
       (auditctl . 0)
      )
    (vl-catch-all-apply 'setvar (list (car x) (cdr x)))
  )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: read only variables?
« Reply #5 on: May 29, 2008, 03:59:09 PM »
uh .. so I am wrong ... me forgot about vl-catch-all DOH!
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

daron

  • Guest
Re: read only variables?
« Reply #6 on: May 29, 2008, 04:26:21 PM »
Oh that's so nice and easy. Thanks Ron and Keith.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: read only variables?
« Reply #7 on: May 29, 2008, 04:34:57 PM »
You're welcome :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

daron

  • Guest
Re: read only variables?
« Reply #8 on: May 29, 2008, 04:49:53 PM »
That works great. Now, anybody who may have gotten the function I've thrown out for simplifying setvars, I hadn't run across RO variables until today, thus this need. So if anyone has taken this or any variation of it, please update your files.
Code: [Select]
(defun remapvars (lst)
     (mapcar '(lambda (x)
   (vl-catch-all-apply 'setvar (list (car x) (cdr x)))
      )
     lst
     )
)