List building question

Discussion in 'AutoCAD' started by Gordon Price, Dec 29, 2003.

  1. Gordon Price

    Gordon Price Guest

    I am trying to build a list of dotted pairs, where one value is actually
    pulled from a current sysvar value. I tried
    '(("cursorsize" . 100)("clayer" . (getvar "clayer")))
    but rather than getting the value of the sysvar I get 'getvar "clayer"'. Am
    I out of luck here and I can't build a list this way?

    Best,
    Gordon
     
    Gordon Price, Dec 29, 2003
    #1
  2. Gordon Price

    Tom Berger Guest

    Quoting a symbol or a list prevents it's evaluation. 'a is just a
    short form for (quote a), and this returns the symbol and not the
    value which is bound to it.

    (list ... (cons "clayer" (getvar "clayer"))) does what you want.

    BTW: the "q" in setq stands for "quote". You want the symbol to be set
    to a value, and not the value of the symbol be set to a value.

    Try this

    (setq test 'a)
    (set test "here-I-am")
    (print test)
    (print a)

    Tom Berger
     
    Tom Berger, Dec 29, 2003
    #2
  3. Gordon Price

    Jeff Mishler Guest

    Try this:
    (list '("cursorsize" . 100)(cons "clayer" (getvar "clayer")))

    Jeff
     
    Jeff Mishler, Dec 29, 2003
    #3
  4. Try (list (cons "cursorsize" . 100)(cons "clayer" . (getvar "clayer")))

    Dan
     
    Daniel Lutzow, Dec 29, 2003
    #4
  5. Gordon Price

    Tom Smith Guest

    It's because you are quoting a list. If the list contains something to be
    evaluated, as yours does, you need something like

    (list
    '("cursorsize" . 100)
    (cons "clayer" (getvar "clayer"))
    )

    You can quote the sublist that doesn't need evaluation, but need to cons the
    other.
     
    Tom Smith, Dec 29, 2003
    #5
  6. Gordon Price

    Gordon Price Guest

    10 minutes, three answers, and it's the Monday between Christmas and New
    Years! This place rocks! Thanks all.

    Gordon
     
    Gordon Price, Dec 29, 2003
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.