My next try show that I get a dialog, where I can "Add" something in the dialog. But if I press than ok the dialog close with "error: bad argument type: stringp nil"
I want that the dialog still show new adding things.
;; function trims text lines
(defun _strtrim (s delims / len s1 i c lst)
(setq delims (vl-string->list delims)
len (strlen s)
s1 ""
i (1+ len))
(while (> (setq i (1- i)) 0)
(setq c (substr s i 1))
(if (member (ascii c) delims)
(if (/= s1 "") ; no null tokens
(setq lst (cons s1 lst)
s1 "")
)
(setq s1 (strcat c s1))
)
)
(if (/= s1 "")
(cons s1 lst) ; no ("" "1" "2")!
lst
)
)
;; function read csv-files
(defun _ReadCSV ( filename / _csv->lst file line)
(defun _csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
(cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
(list str)
)
)
(if (setq file (open filename "r"))
(progn
(while (setq line (read-line file))
(setq lst (cons (_csv->lst line) lst))
)
(close file)
)
)
(setq lst (reverse lst))
)
(defun c:test ( / file tmp dch return)
(cond
(
(not
(and (setq file (open (setq tmp (vl-filename-mktemp nil nil ".dcl")) "w"))
(write-line "
CHAN : dialog {label = \"NOTES\";
: list_box {label = \"Choose Selection :\";key = \"selections\";height = 12;}
: list_box {label = \"Preview :\";key = \"preview\";width = 50;height = 5;}
: boxed_row {
: button {key = \"Okay\";label = \" Okay \";is_default = true;}
: button {key = \"Cancel\";label = \" Cancel \";is_default = false;is_cancel = true;}
: button {key = \"Add\";label = \" Add \";is_default = false;is_cancel = true;}
}
}
ADD : dialog {label = \"Add\";
: row {
: edit_box {key = \"Selection\";label = \"Selection:\";edit_width = 25;height = 1;value = \"\";}
}
: edit_box {key = \"Preview\";label = \"Preview:\";edit_width = 25;height = 1;value = \"\";}
ok_cancel;
} "
file
)
(not (close file))
)
)
)
)
;; Run Dcl menu dialog
(if (<= (setq dcl_id (load_dialog tmp)) 0)
(alert "Error loading DCL file.")
)
(if (not (new_dialog "CHAN" dcl_id))
(alert "Error loading dialog.")
)
(princ)
;; function selects tabell
;; read in dialog
(if (null NAMES)
(setq NAMES (list '("1" "TEST1") '("2" "TEST2") '("3" "TEST3"))) ;testweise
)
(start_list "selections")
(mapcar ' add_list (mapcar 'car NAMES))
(end_list)
(action_tile "selections" (strcat "(progn (setq SIZ $value)"
"(start_list \"preview\")"
"(mapcar ' add_list (setq txt (cdr (assoc (nth (atoi siz)(mapcar 'car NAMES))NAMES))))"
"(end_list)"
"(mode_tile \"accept\" 2))"
)
)
(action_tile "Okay" (strcat "(progn "
"(setq txt (car txt))"
"(done_dialog 1))"
)
)
(action_tile "cancel" "(done_dialog 0)")
(action_tile "Add" (strcat "(if (<= (setq dcl_id (load_dialog tmp)) 0)
(alert \"Error loading DCL file.\")
)"
"(if (not (new_dialog \"ADD\" dcl_id))
(alert \"Error loading dialog.\")
)
(start_dialog)"
)
)
(setq res (start_dialog))
(unload_dialog dcl_id)
(if (= res 1)
(progn
(SETVAR "ORTHOMODE" 0)
(SETVAR "OSMODE" 512)
(SETVAR "DIMTAD" 0)
;;; (PRINC "\nSelect 1ST & 2nd point of leader")
;;; (COMMAND "DIM" "LEADER" PAUSE PAUSE "" txt "EXIT")
(initget "t l ")
(if (setq a (getkword "\nDo you want a [T]ext or a [L]eader ? "))
(cond ((= a "l")
(while (setq pt (getpoint "\nPick a Leader Insert Point ! "))
(command "._mleader" "_non" pt pause txt)
)
)
(T (while (setq pt (getpoint "\nPick a Text Insert Point ! "))
(command "mtext" pt "w" "0" txt "" )
)
)
)
)
(SETVAR "DIMTAD" 1)
(SETVAR "OSMODE" 107)))
(vl-file-delete fname)
(princ)
)
(prompt "\n\t---\tStart command with TEST\t---")
(prin1)
[Edit]
Type in "test", it must open dialog "Notes" and than try to add something. Here I need help.
After typing new values in Add-dialog I want show values in dialog "Notes" (how).