Lists

craigboddington

Usenet Archive
Joined
Jul 25, 2003
Messages
11
Reaction score
0
I have a 'list' of values within a routine. I wish to search through the list untill i get a match with a user entered value, then return the list value to a variable.

Any help would be grate.
 
Here are 2 examples of getting list data

(setq SLIST (list 1 2 3 4 5))
(setq SINPUT (getint "\nInput Number ? "))
(setq SVAL (car (member SINPUT SLIST)))
(princ "\nSVAL=")
(princ SVAL)

(setq LLIST (list (list 1 "A") (list 2 "B") (list 3 "C"))) (setq LINPUT (getint "\nInput Number ? ")) (setq LVAL (assoc LINPUT LLIST)) (princ "\nLVAL=") (princ LVAL) ;this returns a list (2 "B") for example
 
Another alternative

(setq optionList(list (cons (strcase "Option1") "This is option1")(cons (strcase "Option2") "This is Option2"))) (setq opt(strcase(strcat "Option" (getstring "Enter option 1 or 2: ")))) (princ (cdr( assoc opt optionList)))

craigboddington said:
I have a 'list' of values within a routine. I wish to search through the
list untill i get a match with a user entered value, then return the list value to a variable.
 

Latest threads

Back
Top