Hello, I have a lisp code that I have been working on and I have brought it to a certain stage. However, I am having a problem at one point.
In this lisp code, I have a product list with my purpose defined. When the code runs, my product list is listed in the pop-up window. And I choose what I want and paste it to the places I specify on the screen. However, my product list can be up to 500 items, so I created a search button in the popup window. The button works, but it is based on the line number I choose, not the product name I choose, and it writes the product on this line number in the general list to the screen. I need support on how to overcome this problem.
Code:
; main command
(defun C:prdef (/ dcl_id product_list product filter_list pt index)
(create-layer "00-Equipment List" 3) ; Number 3 is used for green color
(setq product_list '("Product-1" "Product-2" "Product-3" "Product-4" "Product-5" "Product-6" "Product-7" "Product-8" "Product-9" "Product-10" "Product-11" "Product-12" "Product-13" "Product-14"))
(setq dcl_id (load_dialog "product_select.dcl"))
(if (not (new_dialog "product_select" dcl_id))
(exit)
)
(start_list "product_list")
(mapcar 'add_list product_list)
(end_list)
(action_tile "search_box" "(progn (setq filter_text $value) (update_list filter_text))")
(action_tile "product_list" "(setq product (nth (atoi $value) product_list))") ;
(action_tile "ok" "(done_dialog)")
(action_tile "search_button" "(update_list filter_text)") ;
(start_dialog)
(unload_dialog dcl_id)
(initget 1)
(while (setq pt (getpoint "\nChoose a location (exit with ESC): "))
(setq index (atoi product)) ;
(command "_.-layer" "_S" "00-Equipment List" "") ;
(command "_.text" pt *default-text-height* 0 product) ;
(command "_.-layer" "_S" "0" "") ;
)
)
; List update function
(defun update_list (filter_text / filtered_list)
(setq filtered_list
(if (= filter_text "")
product_list
(vl-remove-if-not
'(lambda (x) (vl-string-search (strcase filter_text) (strcase x)))
product_list
)
)
)
(start_list "product_list")
(mapcar 'add_list filtered_list)
(end_list)
(set_tile "product_list" "")
)
In my dcl code as follows
Code:
product_select : dialog {
label = "Product Select";
: edit_box {
key = "search_box";
label = "search";
width = 40;
}
: button {
key = "search_button";
label = "search";
is_default = true;
}
: list_box {
key = "product_list";
multiple_select = false;
fixed_width = true;
width = 40;
}
ok_cancel;
}