I don't get it - read stringed association list

Discussion in 'AutoCAD' started by Eric Schneider, Jan 25, 2005.

  1. Why does this work:

    (read (vl-princ-to-string '(("a" 0)("b" 1)("c" 2))))

    but this won't:

    (read (vl-princ-to-string '(("a" . 0)("b" . 1)("c" . 2))))

    ???
     
    Eric Schneider, Jan 25, 2005
    #1
  2. Hi Eric.

    I don't see the value of this without it's context.

    Anyway, this

    (mapcar 'set '(a b)
    (mapcar
    '(lambda (x) (read (vl-princ-to-string x)))
    '(
    (("a" 0)("b" 1)("c" 2))
    (("a" . 0)("b" . 1)("c" . 2))
    )
    )
    )

    !a => ((A 0) (B 1) (C 2))
    !b => ((A . 0) (B . 1) (C . 2))

    Seems to work to me.

    Are you reading data from a data file and then trying
    to convert per the above? Are there spaces or mismatched
    quotes etc that might play into the fray?

    ???
     
    Michael Puckett, Jan 25, 2005
    #2
  3. Eric Schneider

    MP Guest

    maybe reload your session?
    (read (vl-princ-to-string '(("a" 0)("b" 1)("c" 2))))
    ((A 0) (B 1) (C 2))
    _$

    (read (vl-princ-to-string '(("a" . 0)("b" . 1)("c" . 2))))

    ((A . 0) (B . 1) (C . 2))
    _$

    (a2k5 win2k)
    Mark
     
    MP, Jan 25, 2005
    #3
  4. I'm trying to stick an association list into the registry so it has to be a
    string.

    (vl-registry-write "HKEY_CURRENT_USER\\SOFTWARE\\my_stuff" "my_key"
    (vl-princ-to-string '(("cmdecho" . 0)("dimdec" . 2)("dimpost" .
    "<>\"")("dimlunit" . 2)("dimrnd" . 0.01)("dimzin" . 0)(dimtad . 1)(dimtih .
    0))))

    (setq vals (vl-registry-read "HKEY_CURRENT_USER\\SOFTWARE\\my_stuff"
    "my_key"))

    (read vals):puke

    (vl-registry-delete "HKEY_CURRENT_USER\\SOFTWARE\\my_stuff" "my_key")
     
    Eric Schneider, Jan 25, 2005
    #4
  5. There's no reason why either of those shouldn't work,
    although I'd be willing to guess that a missing space
    on either side of the dot in a dotted pair is the culprit.
     
    Tony Tanzillo, Jan 25, 2005
    #5
  6. I'm going to guess the value associated with
    "dimpost" is making it chuck a wobbly.
     
    Michael Puckett, Jan 25, 2005
    #6
  7. (vl-princ-to-string ....

    Wrong function. Try vl-prin1-to-string

    princ/vl-princ-to-string format strings

    print/prin1/vl-prin1-to-string do not format strings.
     
    Tony Tanzillo, Jan 25, 2005
    #7
  8. Doh! <slap forehead>

    Thanks Tony.
    --

    Regards,
    Eric S.
    A2005/W2k
     
    Eric Schneider, Jan 25, 2005
    #8
  9. Eric Schneider

    James Buzbee Guest

    Hey Eric,

    This looks like a standardization thing? Or is for your use only?

    jb
     
    James Buzbee, Jan 26, 2005
    #9
  10. Hey James! Whasup?

    It's for a tool used by my department for ordinate dimensioning in feet,
    inches or radius inches.
     
    Eric Schneider, Jan 26, 2005
    #10
  11. Eric Schneider

    James Buzbee Guest

    Whasuuuuuuuuuppppp! (bad 90's joke)

    Ah, then it changes per user?

    I was going to suggest a central drawing database dictionary if it were
    shared info . . ..

    Nice hearing from you.

    jb
     
    James Buzbee, Jan 26, 2005
    #11
  12. Yeah, it changes per user. It just stores values to use as defaults.
    --

    Regards,
    Eric S.
    A2005/W2k

    I was so there, dude.
     
    Eric Schneider, Jan 28, 2005
    #12
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.