I'm attempting to use the (member) function to check if an item (string) belongs to a list of strings.
All I'm getting is Nil....here are the conditions.
(setq lst (dynamicpropertyallowedvalues (car (entsel)) "*"))Select object: (("Visibility1" "Check Valve" "Flanged Check Valve"))Command: !lst(("Visibility1" "Check Valve" "Flanged Check Valve"))
So that's what I've done to obtain my list, that's a subfunction that is defined elsewhere. Now, when I try to see if a string "Check Valve" is contained within lst, which it obviously is....
Command: (member '"Check Valve" lst)nilCommand: (member "check valve" lst)nilCommand: (member "Visibility1" lst)nilCommand: (setq theitem "Flanged Check Valve")"Flanged Check Valve"Command: (member theitem lst)nil
So that's where I'm at, hoping to gain some understanding as to why my member function isn't returning True or returning a list with the given member item and the following items...
If I'm going about this the wrong way, could someone please inform me as to the proper way to check if a string is contained within a list and how to manipulate it. The lst length should vary, under these conditions I do not want to use (nth) or similar functions because those would not work for what i'm trying to do.
Thanks in advance! You have a list within a list:
_$ (setq lst '(("Visibility1" "Check Valve" "Flanged Check Valve")))(("Visibility1" "Check Valve" "Flanged Check Valve"))_$ (member '("Visibility1" "Check Valve" "Flanged Check Valve") lst)(("Visibility1" "Check Valve" "Flanged Check Valve"))_$ (member "Visibility1" (car lst))("Visibility1" "Check Valve" "Flanged Check Valve")_$ (member "Check Valve" (car lst))("Check Valve" "Flanged Check Valve") Okay, great, that should do....thanks, I'll test it too but I see from your returned info there what needs to happen.
Thanks Lee, once again
Ahhhhh, alright. I see.
(member "Visibility1" (car lst))("Visibility1" "Check Valve" "Flanged Check Valve")
How I would have expected my tests earlier to return is obtained by this method, simply stating adding to look in the first item in the list "lst" , being as there is only the one actual list with data within lst, that's why the (car) function is required. And once it's looking at the lst containing the three strings, and finds "Visibility1" within that list, it returns the entire list.
It does not, however, return True...but I'm assuming that an (if) statement could be wrapped around the (member) statement and if a list is returned (i.e. the item is found in the list), then the if function would proceed to the "then" portion, as if it returned True. This would be easy to test in fact i'll do it now....
Note that this is only because "Visibility1" is the first item in the list supplied to member. Similar to the (cdr) function in that regard, if I had given it "Check Valve" it would return just the 2.......
as shown in your last example.
And similarly
Command: (setq lst '(("Visibility1" "Check Valve" "Flanged Check Valve")))(("Visibility1" "Check Valve" "Flanged Check Valve"))Command: (member "Flanged Check Valve" (car lst))("Flanged Check Valve")
Okay, got it. Thanks again!
页:
1
[2]