Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

present in a list

5 REPLIES 5
Reply
Message 1 of 6
andre_lag
283 Views, 5 Replies

present in a list

Hi,

 

I have a list like ("a.dwg" "b.dwg" "c.dwg")

and an filename "b.dwg"

I want to know if the filename is a part of the list.

which function must be used for this?

---

André

5 REPLIES 5
Message 2 of 6
_Tharwat
in reply to: andre_lag


@andre_lag wrote:

which function must be used for this?

 


 

Use member function .

Message 3 of 6
devitg
in reply to: andre_lag

(setq dwg-list (list "a.dwg" "b.dwg" "c.dwg"))

(setq dwg-to-search "b.dwg")

(if (member dwg-to-search dwg-list)
(alert (strcat  "\n" dwg-to-search "  exists"   ))
(alert (strcat "\n"  dwg-to-search "  do not exists"))
)        

 

Message 4 of 6
_Tharwat
in reply to: andre_lag

Another with function vl-position .

 


(setq lst (list "a.dwg" "b.dwg" "c.dwg"))
(if (vl-position "b.dwg" lst)
  (alert "File name is found")
  (alert "File name not found")
)

 Tharwat

Message 5 of 6
_Tharwat
in reply to: andre_lag

Another with foreach function

 

(foreach x (list "a.dwg" "b.dwg" "c.dwg")
  (if (eq "b.dwg" x)
    (setq found t)
  )
)
(if found (alert "File name is found"))

 

Message 6 of 6
andre_lag
in reply to: andre_lag

Thanks guys,

 

all suggestions works in my routine

 

---

André

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost