(if (> (setq dcl_id (load_dialog "#txt")) 0);加载对话框文件
(progn
(if (new_dialog "filetext" dcl [JX*6]id); 显示对话框
(progn start_list "what");将词组显示到列表框内
(mapcar 'add_list txt_tb
)
(end_list)
(setq i 1)
(repeat nn;点取词组分类项后的操作
(action_tile (strcat "c" (itoa i)) "(wr_txt)")
(setq i (1+ i))
)
(action_tile "what" "(setq i (atoi $value));选中词组
(setq txt (nth i txt_tb))(set_tile \"sel_ok\" txt)"
)
(action_tile "sel_ok" "(setq txt $value)")
(action_tile "accept" "(setq ok T)(done_dialog 1)(unload_dialog dcl_id)")
(action_tile "cancel" "(unload_dialog dcl_id)")
(start_dialog)
)
(prompt "\n无法显示对话框FILETEXT! 请检查对话框内容!")
)
)
(prompt "\n无法加载对话框文件#TXT.DCL! 请检查文件是否存在及路径是否正确!")
)
)
; 初始化程序, 把第1个分组项中的词组读入表txt_tb中
(defun init( / fname fp txt1)
(setq fname (findfile "$txt1.dat"))
(if (not fname)
(progn (princ "\n文件 $TXT1.DAT 不存在 !") (exit)) ; 文件不存在, 则退出
)
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp))
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
(setq old_nn 1);记录索引号
)
; 更换列表框内词组显示内容
(defun wr_txt ( / fname fname1 fp txt1 i)
(setq i 1)
(while (<= i nn); 判别哪个词组项被点中
(if (= (get_tile (strcat "c" (itoa i))) "1")
(setq fname1 (strcat "$txt" (itoa i) ".dat")
i nn
)
)
(setq i (1+ i))
)
(if (setq fname (findfile fname1)); 查找文件是否存在
(progn
(setq old_nn (atoi (substr fname1 5)));记录索引号
(setq fp (open fname "r"))
(setq txt_tb '())
(while (setq txt1 (read_line fp));依次读出各词组
(setq txt_tb (cons txt1 txt_tb))
)
(close fp)
(setq txt_tb (reverse txt_tb))
(start_list "what");在列表框内显示词组内容
(mapcar 'add_list txt_tb)
(end_list)
) ; progn
(progn
(alert (strcat "文件" fname1 "不存在!"))
(set_tile (strcat "c" (itoa old_nn)) "1");恢复原记录号

