Need help with DCL multiple_select

Discussion in 'AutoCAD' started by Daniel J. Altamura, R.A., Apr 24, 2004.

  1. Up until now I have never had a need to select multiple items from a DCL
    list box. I have the tile set to multiple_select = true in the DCL, but I
    can't figure out how to convert the results of the selection to what I need.
    The results are the number positions of the selected list items, as a
    string. I would like to convert this string into a list, but how?
    VL-String->LIST doesn't quite work.

    This is what I have: "2 4 6 7 9"
    This is what I want: (2 4 6 7 9) or ("2" "4" "6" "7" "9")

    Is there a better, or easier way to handle multiple selections from list
    boxes? How can I use these results to find out which items have been
    selected? Do I have to parse the string? Thanks for any help. I'm going
    around in circles on this one.

    Dan
     
    Daniel J. Altamura, R.A., Apr 24, 2004
    #1
  2. There are a few ways to skin this cat; meow.

    Here is one possible way ...

    (setq ItemsSelected
    (mapcar
    '(lambda (x) (nth x TheListYouUsedToPopulateTheListBox))
    (read (strcat (chr 40) (get_tile "TheNameOfTheListTile") (chr 41)))
    )
    )

    <In theory> It should work whether you have selected
    no items, one item, or multiple items, though I didn't
    actually try it :S

    PS, I used (chr 40) (chr 41) because I hate stringed
    parenthesis in my code; a peeve.

    HTH,

    Cheers.
     
    michael puckett, Apr 24, 2004
    #2
  3. Thanks for the help. I wasn't able to make get_tile work, but I found the
    following function in help, and got it to work for me.

    "The following definition of MK_LIST returns a list containing only items
    the user has selected from the original displist. (In this example, the
    display list displist is maintained as a global variable.) The MK_LIST
    function expects to be called with the current $value of the list box:"

    (defun MK_LIST (readlist / count item retlist)
    (setq count 1)
    (while (setq item (read readlist))
    (setq retlist (cons (nth item displist) retlist))
    (while (and (/= " " (substr readlist count 1))
    (/= "" (substr readlist count 1)))
    (setq count (1+ count))
    )
    (setq readlist (substr readlist count))
    )
    (reverse retlist)
    )
     
    Daniel J. Altamura, R.A., Apr 25, 2004
    #3
  4. I have a subroutine I use to strip a string -

    ;--subroutine to take text with char (ex.~) & create
    list-------------------
    (defun GETTEXTLIST (STR_TEXT CHAR / CHAR_LEN KKS KKK KKL)
    (setq LIST_TEXT nil)
    (setq CHAR_LEN (strlen CHAR))
    (setq KKS 1 KKK 1 KKL (strlen STR_TEXT))
    (while (<= KKK KKL)
    (if (= (substr STR_TEXT KKK CHAR_LEN) CHAR)
    (progn
    (setq LIST_TEXT (append LIST_TEXT (list (substr STR_TEXT KKS (- KKK
    KKS)))))
    (setq KKS (+ KKK CHAR_LEN))
    )
    )
    (setq KKK (1+ KKK))
    )
    (setq LIST_TEXT (append LIST_TEXT (list (substr STR_TEXT KKS))))
    )

    Call be (GETTEXTLIST "This is a Test String" " ") returns ("This" "is" "a"
    "Test" "String")
    Note that the CHAR can be more than 1 character long - example -
    (GETTEXTLIST "A12B12C" "12") returns ("A" "B" "C")
     
    Alan Henderson, Apr 25, 2004
    #4
  5. Thanks for the routine Alan. I like the fact that you can specify the
    delimeter character.

    Dan
     
    Daniel J. Altamura, R.A., Apr 25, 2004
    #5
  6. Daniel J. Altamura, R.A.

    John Uhden Guest

    This is the easiest method you can find...
    Presuming (setq selection (get_tile tile)) returns the string "2 3 5 7 9", then
    (setq selection (read (strcat "(" selection ")")))
    will return a list of integers... '(2 3 5 7 9)
     
    John Uhden, Apr 26, 2004
    #6
  7. Thanks John, that does look easy. I will check it out.

    Dan
     
    Daniel J. Altamura, R.A., Apr 26, 2004
    #7
  8. Daniel J. Altamura, R.A.

    cwanless Guest

    Hi take a look at ObjectDCL from www.objectdcl.com. It gives you the ability to extract a list of the selected item strings in the list and it also allows you to extract a list of index values of the selected items in the list as well.

    Thanks Chad Wanless
     
    cwanless, Apr 26, 2004
    #8
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.