DATVO Posted October 23, 2023 Share Posted October 23, 2023 Hi. Please help me with this code, i'm stuck with it, the mleader cant get content from filtboxlist (Lee Mac) : (defun c:demo (/ ans) (setq ans (LM:filtlistbox "Pick up a contents" '( "Item1" "Item2" ) 60 20 ) ) (command "_mleader" pause pause ans) ) ; end_defun ;; Filtered List Box - Lee Mac ;; Displays a list box interface from which the user may select one or more items. ;; Includes an edit box filter to enable the user to filter the displayed list of items. ;; msg - [str] List box dialog title ;; lst - [lst] List of strings to display in the list box ;; mtp - [bol] T=Allow multiple items; nil=Single item selection ;; Returns: [lst] List of selected items, else nil (defun LM:filtlistbox ( msg lst mtp / _addlist dch dcl des rtn sel tmp ) (defun _addlist ( key lst ) (start_list key) (foreach x lst (add_list x)) (end_list) lst ) (if (and (setq dcl (vl-filename-mktemp nil nil ".dcl")) (setq des (open dcl "w")) (write-line (strcat "filtlistbox : dialog { label = \"" msg "\"; spacer;" ": list_box { key = \"lst\"; width = 50; fixed_width = true; height = 15; fixed_height = true; allow_accept = true; " "multiple_select = " (if mtp "true" "false") "; }" ": edit_box { key = \"flt\"; width = 50; fixed_width = true; label = \"Filter:\"; }" "spacer; ok_cancel; }" ) des ) (not (close des)) (< 0 (setq dch (load_dialog dcl))) (new_dialog "filtlistbox" dch) ) (progn (_addlist "lst" (setq tmp lst)) (set_tile "lst" (setq rtn "0")) (set_tile "flt" "*") (action_tile "lst" "(setq rtn $value)") (action_tile "flt" (vl-prin1-to-string '(progn (setq flt (strcat "*" (strcase $value) "*") sel (mapcar '(lambda ( n ) (nth n tmp)) (read (strcat "(" rtn ")"))) ) (_addlist "lst" (setq tmp (vl-remove-if-not '(lambda ( x ) (wcmatch (strcase x) flt)) lst))) (set_tile "lst" (setq rtn (vl-string-trim "()" (vl-princ-to-string (cond ( (vl-sort (vl-remove nil (mapcar '(lambda ( x ) (vl-position x tmp)) sel)) '<)) ( '(0) ) ) ) ) ) ) ) ) ) (setq rtn (if (= 1 (start_dialog)) (mapcar '(lambda ( x ) (nth x tmp)) (read (strcat "(" rtn ")"))) ) ) ) ) (if (< 0 dch) (setq dch (unload_dialog dch)) ) (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl) ) rtn ) Quote Link to comment Share on other sites More sharing options...
exceed Posted October 23, 2023 Share Posted October 23, 2023 http://www.lee-mac.com/filtlistbox.html If you read the example in this link carefully, the snippet requires 3 arguments. If you want to insert numeric values into item1 and item2, you will have to create 1 list and then extract it, or just hard coding it and process it with the (cond) statement. Quote Link to comment Share on other sites More sharing options...
DATVO Posted October 23, 2023 Share Posted October 23, 2023 2 hours ago, exceed said: http://www.lee-mac.com/filtlistbox.html If you read the example in this link carefully, the snippet requires 3 arguments. If you want to insert numeric values into item1 and item2, you will have to create 1 list and then extract it, or just hard coding it and process it with the (cond) statement. Hi, I’m new to Lisp programming. Could you help me in a more detailed way? Quote Link to comment Share on other sites More sharing options...
exceed Posted October 23, 2023 Share Posted October 23, 2023 (defun c:demo (/ ans) (setq ans (LM:filtlistbox "Pick up a contents" '( "60" "20" ) nil ) ) (command "_mleader" pause pause (car ans)) ) ; end_defun I don't know what you want to put in mleader just by looking at the code, but I guessed that you wanted to put 60 or 20, and changed it like this. Quote Link to comment Share on other sites More sharing options...
DATVO Posted October 23, 2023 Share Posted October 23, 2023 5 minutes ago, exceed said: (defun c:demo (/ ans) (setq ans (LM:filtlistbox "Pick up a contents" '( "60" "20" ) nil ) ) (command "_mleader" pause pause (car ans)) ) ; end_defun I don't know what you want to put in mleader just by looking at the code, but I guessed that you wanted to put 60 or 20, and changed it like this. sorry, I’m going to insert some text into mleader from filtlistbox, for example: “content1” and “content2”.... Quote Link to comment Share on other sites More sharing options...
exceed Posted October 23, 2023 Share Posted October 23, 2023 (defun c:demo (/ ans) (setq ans (LM:filtlistbox "Pick up a contents" '( "Content1" "Content2" "Almost heaven" "West Virginia" "Blue Ridge Mountains" "Shenandoah River" ) nil ) ) (command "_mleader" pause pause (car ans)) ) ; end_defun It's as simple as just changing the value between " and " to the value you want. 1 Quote Link to comment Share on other sites More sharing options...
DATVO Posted October 23, 2023 Share Posted October 23, 2023 14 minutes ago, exceed said: (defun c:demo (/ ans) (setq ans (LM:filtlistbox "Pick up a contents" '( "Content1" "Content2" "Almost heaven" "West Virginia" "Blue Ridge Mountains" "Shenandoah River" ) nil ) ) (command "_mleader" pause pause (car ans)) ) ; end_defun It's as simple as just changing the value between " and " to the value you want. Thanks so much for your help, you save me a lot !! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.