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

0 Members and 1 Guest are viewing this topic.

vincent.r

  • Newt
  • Posts: 101
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: 1451
  • 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, ...?

vincent.r

  • Newt
  • Posts: 101
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

  • Newt
  • Posts: 101
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: 1451
  • 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")

vincent.r

  • Newt
  • Posts: 101
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.


ronjonp

  • Needs a day job
  • Posts: 7526
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 11 x64 - AutoCAD /C3D 2023

Custom Build PC