Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Quick question guys,
It's a sort of general DCL sub originally made by Ronjonp... can't figure out what to add to accept the first line by default by hitting Enter (if multiple_select is allowed)
Load - Enter returns nil, I want '("0") for the following test func
thx
(defun c:test ()
(defun :DclList (title lst multi / ch flg tmp file id lst)
;; based of ronjonp's code
(if (and (setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq file (open tmp "w"))
(write-line (strcat "Dcllist : dialog { initial_focus = \"l\"; label = \"" title
"\";spacer;: row {: list_box {key = \"l\"; alignment = centered; width = "
(itoa (min (+ 10 (car (vl-sort (mapcar 'strlen (mapcar 'vl-princ-to-string lst)) '>))) (fix (/ (car (getvar 'screensize)) 10))))
"; height = " (itoa (min (+ 3 (length lst)) (fix (/ (cadr (getvar 'screensize)) 12))))
";" (if multi " multiple_select = true;" " multiple_select
= false;") " allow_accept = true;"
"}}spacer;ok_cancel;}")
file)
(not (close file)))
(progn
(setq id (load_dialog tmp))
(new_dialog "Dcllist" id)
(start_list "l")
(mapcar 'add_list (mapcar '(lambda (x) (vl-princ-to-string x)) lst)) (end_list)
(set_tile "l" "0") ; to highlight initial row
(action_tile "l" "(setq ch $value)")
(setq flg (start_dialog))
(unload_dialog id)
(vl-file-delete tmp)
(if (and ch (= 1 flg))
(mapcar '(lambda (x) (nth x lst)) (read (strcat "(" ch ")")))))))
(:DclList "title" '("0" "1" "2" "3") t))
Solved! Go to Solution.