V20 set/get variables

I am used to set variables with an _ so it's language irrelevant.
I do it like this on several places and ways:
in script as: _setvar _variable VALUE or _variable VALUE
in lisp as (_setvar "_variable" VALUE) and (_getvar "_variable")
in COM (C#) as: AcadApplication.ActiveDocument.SetVariable("_variable", 1);

It now seems that in V20 you should no longer use the _ in the variable name.

the _variable VALUE as command still works, but all other no longer work.

Was this done intentionally? Is it described anywhere?

Regards,

Karel

Comments

  • I also see inconsistency: For example the difference between saveformat and vernum:
    (getvar "saveformat")
    4
    (getvar "_saveformat")
    nil
    (getvar "vernum")
    nil
    (getvar "_vernum")
    "20.1.01 (UNICODE)"

    For vernum, the _ is needed. Checking the settings dialog I see that saveformat has no _, and _vernum does (looking at the variable name in the lower left corner of the settings dialog)

  • Dear Karel,

    1. system variables are never translated, so the underscore _ is not necessary at all, especially not in API level calls (setvar(getvar "saveformat")
    2. when using without API, like on your script file, the variable name is entered as COMMAND ... and here, the _ is used to distinguihs "localised" vs. "global(english)" command name - which is identical for system variables (as not being translated)
    3. there are a very few system variables, which have the underscore as part of their native name like "_vernum" ... I think there are 2,3 more system variables using the underscore as native name part, but rarely used

    In short - via APIs (Lisp/NET etc.), use the plain system variable name ...
    in scripts, underscore can be used (but has no effect) - so even in scripts, using (setvar/getvar ...) is the better approach :-)

    man ygreetings !

  • Torsten,

    thanks for the clarification!

    Karel

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!