Hi,
Another way is to write the DCL from the LISP in a temporary file.
Here's a little example:
Code:
;; ListBox (gile)
;; Dialog box which allows a single or multple choice
;;
;; Arguments:
;; title : dialog title (string)
;; msg ; message (string), "" or nil for none
;; keylab : assoc list which type is ((key1 . label1) (key2 . label2) ...)
;; flag : 0 = popup list
;; 1 = single choice list
;; 2 = multiple choice list
;;
;; Return : the key of the choosen option (flag = 0 or 1) or the key list (flag = 2)
;;
;; Example:
;; (listbox "Layout" "Choose a layout" (mapcar 'cons (layoutlist) (layoutlist)) 1)
(defun ListBox (title msg keylab flag / tmp file dcl_id choice)
(setq tmp (vl-filename-mktemp "tmp.dcl")
file (open tmp "w")
)
(write-line
(strcat "ListBox:dialog{label=\"" title "\";")
file
)
(if (and msg (/= msg ""))
(write-line (strcat ":text{label=\"" msg "\";}") file)
)
(write-line
(cond
((= 0 flag) "spacer;:popup_list{key=\"lst\";")
((= 1 flag) "spacer;:list_box{key=\"lst\";")
(T "spacer;:list_box{key=\"lst\";multiple_select=true;")
)
file
)
(write-line "}spacer;ok_cancel;}" file)
(close file)
(setq dcl_id (load_dialog tmp))
(if (not (new_dialog "ListBox" dcl_id))
(exit)
)
(start_list "lst")
(mapcar 'add_list (mapcar 'cdr keylab))
(end_list)
(action_tile
"accept"
"(or (= (get_tile \"lst\") \"\")
(if (= 2 flag) (progn
(foreach n (str2lst (get_tile \"lst\") \" \")
(setq choice (cons (nth (atoi n) (mapcar 'car keylab)) choice)))
(setq choice (reverse choice)))
(setq choice (nth (atoi (get_tile \"lst\")) (mapcar 'car keylab)))))
(done_dialog)"
)
(start_dialog)
(unload_dialog dcl_id)
(vl-file-delete tmp)
choice
)
;; STR2LST
;; Transforms a string with separator into a list of strings
;;
;; Arguments
;; str = the string
;; sep = the separator pattern
(defun str2lst (str sep / pos)
(if (setq pos (vl-string-search sep str))
(cons (substr str 1 pos)
(str2lst (substr str (+ (strlen sep) pos 1)) sep)
)
(list str)
)
)
This way, allows to create the dialog box differently according to parameters got by the LISP before writing the file.
In the attached file, SSD is used to make a dynamic blocks selection filtered by their dynamic properties. The dialog box to choose the properties is created after the choice of a target block and matches its dynamic properties.