Lists

Discussion in 'AutoCAD' started by craigboddington, Jan 16, 2004.

  1. 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.
     
    craigboddington, Jan 16, 2004
    #1
  2. 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
     
    Alan Henderson, Jan 16, 2004
    #2
  3. craigboddington

    RDI Guest

    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)))

    list untill i get a match with a user entered value, then return the list
    value to a variable.
     
    RDI, Jan 16, 2004
    #3
  4. cheers for all you help lads.
     
    craigboddington, Jan 17, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.