Author Topic: Adding string to list..  (Read 2293 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Adding string to list..
« on: January 15, 2007, 02:59:20 PM »
Hi all,..

Can any one tell me how I can add string to list...

Code: [Select]
(setq list1  "A11,A11v,A01,A01v,A21,A31,A41")
(setq ss2 (ssget "X" '(( 0 . "INSERT " ))))
'(
    (-4 . "<AND ")
    (0 . "INSERT ")
    (-4 . "<NOT ")
    (2 . list1)   ;;;;;;;      <----- ???
    (-4 . "NOT>")   
    (-4 . "AND>")
)))

thanks.
Keep smile...

uncoolperson

  • Guest
Re: Adding string to list..
« Reply #1 on: January 15, 2007, 03:06:20 PM »
use some (cons)


Code: [Select]
(list
    '(-4 . "<AND ")
    '(0 . "INSERT ")
    '(-4 . "<NOT ")
    (cons 2 . list1)
    '(-4 . "NOT>")   
    '(-4 . "AND>")
)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Adding string to list..
« Reply #2 on: January 15, 2007, 03:11:24 PM »
uncoop...

Thanks..
to many work here....no time to think  :oops:

thanks again.
Keep smile...

Fatty

  • Guest
Re: Adding string to list..
« Reply #3 on: January 15, 2007, 03:12:08 PM »
I use cons instead of quoted list always
Something like this:

Code: [Select]
(setq ss2 (ssget "X" (list
              (cons -4  "<AND ")
              (cons 0  "INSERT ")
              (cons -4  "<NOT ")
              (cons 2  list1)   
              (cons -4 "NOT>")   
              (cons -4  "AND>")
              )))

~'J'~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Adding string to list..
« Reply #4 on: January 15, 2007, 08:35:23 PM »
You can try this:
Code: [Select]
(setq lst '( "A11"
      "A11v" "A01"
      "A01v" "A21"
      "A31"  "A41"
))
(setq ss2 (ssget "_X"
                 (cons '(0 . "INSERT")
                       (mapcar '(lambda (x) (cons [color=red]2[/color] (strcat "~" x))) lst)
                 )
          )
)

Oops, Thanks Kerry.
Yes, I was actually testing with TEXT objects and forgot to change that back.
  :oops:
« Last Edit: January 16, 2007, 08:00:03 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Adding string to list..
« Reply #5 on: January 16, 2007, 06:30:44 AM »
I think Alan meant (cons 2 .... not (cons 1 ...
Code: [Select]
(setq ss2 (ssget "_X"
                 (cons '(0 . "INSERT")
                       (mapcar '(lambda (x) (cons 2 (strcat "~" x))) lst)
                 )
          )
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.