; listbox-ah a library lst box routine pick just one from 
; By Alan H March 2019

; code use
; (if (not AHlstbox)(load "Listbox-AH.lsp"))
; (setq ans (ahlstbox "Pick a number" (list "150" "200" "225" "250" "300" "375" "450" "600") 20 10))
; ans is returned as  item number selected of the list

(defun AHlstbox (heading lst wid ht / fo fname)
(setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w"))
(write-line "AHlstbox : dialog {" fo)
(write-line   (strcat " label = " (chr 34) heading (chr 34)  "  ;" )   fo)
(write-line   "    spacer  ; " fo)
(write-line   "    :list_box { " fo)
(write-line (strcat " key=" (chr 34) "lst" (chr 34) " ; ") fo)
(write-line  (strcat "    multiple_select=" (chr 34) "false" (chr 34)  " ; ") fo)
(write-line   (strcat "    width= " (rtos wid 2 0) " ; ") fo)
(write-line   (strcat "    height=" (rtos ht 2 0 ) " ; ") fo)
(write-line   "    }   " fo)
(write-line   "spacer ;" fo)
(write-line    "   ok_cancel ; " fo)
(write-line "  } " fo)
(close fo)
(setq dcl_id (load_dialog fname))
(if (not (new_dialog "AHlstbox" dcl_id))
    (exit)
)
(start_list "lst")
(foreach itm lst (add_list itm))
(end_list)
(action_tile "lst" "(setq sellst $value)")
(action_tile "accept" "(done_dialog)")
(start_dialog)
(unload_dialog dcl_id)
(princ sellst)
(vl-file-delete fname)
(princ)
)
