TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: RGUS on August 03, 2018, 12:46:28 AM

Title: List Creation from Variables
Post by: RGUS on August 03, 2018, 12:46:28 AM
Hi,
I'm obviously not very good at list handling because I just don't know how to get the format right for the creating this list.

I've got this:

(setvar "dimscale" 100)
(setq tag0 "A3-SCALE")
(setq value0 (strcat "1:" (rtos (getvar "dimscale"))))
 
(setq lst  '((list tag0 value0)
            ("tag1" "value1")
      )
)

It returns:
((list TAG0 VALUE0) ("tag1" "value1"))

I'd like it to return:
(("A3-SCALE" "1:100") ("tag1" "value1"))
complete with all the braces in the right place.

Is this not possible or maybe I'm simpler than I thought?
Thanks for any help.

Title: Re: List Creation from Variables
Post by: kpblc on August 03, 2018, 01:08:38 AM
Code - Auto/Visual Lisp: [Select]
  1. (setq lst  (list (list tag0 value0) '("tag1" "value1")))
Title: Re: List Creation from Variables
Post by: RGUS on August 03, 2018, 01:28:30 AM
Code - Auto/Visual Lisp: [Select]
  1. (setq lst  (list (list tag0 value0) '("tag1" "value1")))

Thanks so much, I knew it was a mixture of "list" and "'" that would make it work.
 
Title: Re: List Creation from Variables
Post by: tombu on August 03, 2018, 07:22:11 AM
Good explanation by Lee Mac: http://www.lee-mac.com/quote.html