Man, you make it hard to test your stuff with that one file per function idea! Is it that VIM again?
Mark, I have a few comments. Got a few deadly crashes with your program but I didn't have time to see where they came from. Once I added a FINDFILE in READ-USER-XNOTES it didn't happen again.
Also, in the dialog function, wouldn't you rather have the chosen list item appear in the edit box? Of course, it should have a reset option if a note exists already.
Below are some small suggestions to the dialog code, such as offering edit of a chosen note and moving the OK processing outside of the dialog (it came up with empty $value)
(defun read-user-xnotes (/ xenv fo lst)
(if (setq xenv (getenv "user-xnotes"))
(if (not (findfile xenv))
(progn
(setenv "user-xnotes" "")
(alert
"user notes files missing \n will now reset environment"
)
(setq xenv (set-user-xnotes-env))
)
)
(setq xenv (set-user-xnotes-env))
)
(if xenv
(progn
;; {* changed
;; only go ahead and open if xenv is actually found
(cond ((setq xenv (findfile xenv))
(setq fo (open xenv "r"))
(while (setq each-line (read-line fo))
(setq lst (cons each-line lst))
)
(close fo)
)
)
;; changed *}
)
)
;; btw, if statement is redundant :)
(if lst (reverse lst))
)
(defun xnotes-dialog
(msg note_type / dcl_id note action addval getNote)
(defun getNote (val lst)
(set_tile "addnote" (nth (atoi $value) lst))
)
(setq dcl_id (load_dialog "xnotes.dcl"))
(if (not (new_dialog "xdialog" dcl_id))
(exit)
)
(start_list "xnotelst")
(setq tmplst (read-user-xnotes))
(mapcar 'add_list tmplst)
(end_list)
(set_tile "note_t" note_type)
(set_tile "addnote" msg)
(mode_tile "addnote" 3)
;;{* added
(action_tile "xnotelst" "(setq addval (getNote $value tmplst))")
(action_tile "addnote" "(setq addval $value)")
;; a reset tile would be good (just gray it out if note doesn't exist)
;; added *}
;; {* removed
;;; (action_tile
;;; "accept"
;;; "(progn
;;; (setq val1 (get_tile \"xnotelst\"))
;;; (setq val2 (get_tile \"addnote\"))
;;; (done_dialog)
;;; )"
;;; )
;;; (action_tile
;;; "cancel"
;;; "(progn (done_dialog) (exit))"
;;; )
;; removed *}
;; {* changed
(setq action (start_dialog))
;; changed *}
;; {* added
(cond ((= action 1)
(setq note addval)
)
((setq note ""))
)
;; added *}
(unload_dialog dcl_id)
;; {* removed
;;; (if (or val1 val2)
;;; (if (= val1 "")
;;; (setq note val2)
;;; ; else
;;; (setq note (nth (atoi val1) tmplst))
;;; )
;;; )
;; removed *}
note
)