Author Topic: Add string to predefined List  (Read 176 times)

0 Members and 1 Guest are viewing this topic.

vincent.r

  • Mosquito
  • Posts: 14
Add string to predefined List
« on: September 05, 2017, 02:36:54 am »
I am newbie to autolisp, I am trying to add a string "MVTTPL-101-DB-11_1" to a predefined list i.e. (setq shrirfi '(fnames)).
I have googled this but could not get solution ? Can anybody help ?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 736
  • Marco
Re: Add string to predefined List
« Reply #1 on: September 05, 2017, 03:05:41 am »
>> (setq shrirfi '(fnames))

What is fnames? string, list, ...?
Marc'Antonio Alessi http://alessi.xoom.it//alessi/  Coding manual: http://tinyurl.com/zza7ega

vincent.r

  • Mosquito
  • Posts: 14
Re: Add string to predefined List
« Reply #2 on: September 05, 2017, 03:24:44 am »
its a string in a list. want to some more strings next to fnames.

vincent.r

  • Mosquito
  • Posts: 14
Re: Add string to predefined List
« Reply #3 on: September 05, 2017, 03:26:24 am »
my mistake. actually it is (setq shrirfi '("fnames")).

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 736
  • Marco
Re: Add string to predefined List
« Reply #4 on: September 05, 2017, 04:09:09 am »
Maybe:
Code: [Select]
Comando: (setq shrirfi '("fnames"))
("fnames")

Comando: (setq shrirfi (cons "MVTTPL-101-DB-11_1" shrirfi))
("MVTTPL-101-DB-11_1" "fnames")

Comando: !shrirfi
("MVTTPL-101-DB-11_1" "fnames")
Marc'Antonio Alessi http://alessi.xoom.it//alessi/  Coding manual: http://tinyurl.com/zza7ega

vincent.r

  • Mosquito
  • Posts: 14
Re: Add string to predefined List
« Reply #5 on: September 05, 2017, 04:38:45 am »
It works great. Thanks Marc'Antonio Alessi. I was trying with append function, now I will use reverse.

Thanks again for your quick reply.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 736
  • Marco
Re: Add string to predefined List
« Reply #6 on: September 05, 2017, 05:09:04 am »
...append is slower

 :-)
Marc'Antonio Alessi http://alessi.xoom.it//alessi/  Coding manual: http://tinyurl.com/zza7ega

ronjonp

  • Needs a day job
  • Posts: 6401
Re: Add string to predefined List
« Reply #7 on: September 05, 2017, 11:28:06 am »
If you don't want to reverse your list just use append as you mentioned: (append shrirfi '("MVTTPL-101-DB-11_1"))

Windows 10 x64 - AutoCAD /C3D 2018

Custom Build PC