DCL动态对话框求助
求高手帮忙:要求,在主对话框里面点选单选按钮“新建工程”用户在下面输入工程名称,然后在指定盘符里生成一个文件夹,文件夹名称为用户输入的工程名称,用户点选“添加“按钮后弹出一个动态对话框,点击动态对话框上的确定按钮后在刚刚生成文件夹下面生成一个.txt文本文件并记录动态对话框里的内容,同时在下面的列表框里生成一个编号。选择列表框里的编号弹出对应的动态对话框(即生成编号前是怎么样就是怎么样的弹出来,也还可以继续添加删除行数,修改里面的内容),再点击确定按钮后修改对应的.TXT文本文件里面的内容。点”删除“按钮就删除编号及对应的.txt文本文件!现在”添加” “删除”按钮的功能基本实现,就是“修改”按钮的不知道怎么弄了!两个单选按钮的功能应该也不难实现,现在就卡在了这个“修改”按钮这里了,求各位老师帮忙弄一下,或者有类似的lisp语言的例子给参考一下也行!
只要能帮忙实现“修改”按钮的功能都给币了!;;修改按钮还有问题
(defun c:mjbianhao()
(setq t1 (getvar "CDATE"));;计时开始------
(setq mjbh-3(list "4" "6" "8"))
(setq mjbh-5(list "T" "Z" "U"))
(setq os(getvar "osmode"))
(setvar "osmode" 0)
(setq mjbh0(load_dialog "F:\\“终极软件”\\试验编辑中程序\\mjtysj.dcl"))
(if(< mjbh0 0)(exit))
(setq mjstd 1)
(setq mjbh6 '())
(setq mjbh9 '()mjbh12 '())
(while(< mjstd 10)
(if(not(new_dialog "mjtysj" mjbh0))(exit))
(if(/= mjbh6 nil)
(progn
(start_list "mjlbk");;打开关键字为mjlbk的列表
(mapcar'add_list mjbh6);;依次向列表添加表项
(end_list);;结束当前列表控件的处理
);;progn
);;if
;;; (set_tile "mhyyxwzxd" mjbh6)
(action_tile "mjxj" "(MODE_TILE \"mjdq1\" 1)(MODE_TILE \"mjdq2\" 1)(MODE_TILE \"mjxj1\" 0)(MODE_TILE \"mjxj2\" 0)");;设置点击单选按钮后下面两行控件变灰
(action_tile "mjdq" "(MODE_TILE \"mjxj1\" 1)(MODE_TILE \"mjxj2\" 1)(MODE_TILE \"mjdq1\" 0)(MODE_TILE \"mjdq2\" 0)");;设置点击单选按钮后下面两行控件变灰
(action_tile "mjtysj5" "(mjtjzcx)(done_dialog 2)");;点“添加”按钮后从新加载对话框并更新控件mhyyxwzxd
(action_tile "mjtysj6" "(mjxgzcx)(done_dialog 3)");;修改按钮的动作
(action_tile "mjtysj7" "(mjsczcx)(done_dialog 4)");;删除按钮的动作
(action_tile "accept" "(取得数据的子程序)(done_dialog 10)");;确定按钮的动作
(action_tile "cancel" "(done_dialog 11)");;取消按钮的动作
(setq mjstd(start_dialog))
);while
(unload_dialog mjbh0)
(setq t2 (getvar "CDATE"));;计时结束------
(princ "\n程序共用时=")
(princ (* (- t2 t1) 1e6))
(princ "秒")
)
(defun mjxgzcx();;取得对应编号对应的文本文件里面的内容(点击修改按钮会调用此程序)
(setq mjxgzcx8 '() mjxgzcx7 '())
(if (= (setq mjxgzcx1(reverse(vl-directory-files "F:\\编号内容" "*"))) nil) (vl-mkdir "F:\\编号内容"));;判断指定的文件夹是否存在,如果不存在则新建之
(setq mjxgzcx1(reverse(vl-directory-files "F:\\编号内容" "*.txt")));;取到指定路径下的所有txt文件(文本文件)并把返回的文件列表倒序
(setq mjxgzcx2(length mjxgzcx1));;取到读取到的文本文件个数
(setq mjxgzcx3(get_tile "mjlbk"));;取得下拉列表的返回值
(setq mjxgzcx4(strcat "F:\\编号内容\\" (nth (atoi mjxgzcx3) mjxgzcx1)));;取到指定路径下指定的第几个文本文件(这里的1要改成mjxgzcx3)
(setq mjxgzcx5(open mjxgzcx4 "r"));;打开指定的文件
(setq mjxgzcx6(read(read-line mjxgzcx5)));;读取指定文件
(setq mjxgzcx7(cons mjxgzcx6 mjxgzcx7))
(while mjxgzcx6;;循环将取得的内容组合成一个列表
(setq mjxgzcx6(read-line mjxgzcx5));;读取指定文件
(if (/= mjxgzcx6 nil);;判断如果读取文本文件里的内容不为空就添加到列表里
(setq mjxgzcx7(cons mjxgzcx6 mjxgzcx7));;将从文本文件里面取得的数据组合成一个列表
);;if
);;while
(close mjxgzcx5)
(setq mjxgzcx8(reverse mjxgzcx7));;将列表倒序
(tt1)
(princ)
)
(defun mjtjxgzcx();;写入文本子程序(添加和修改按钮都要调用到的子程序)
;;;(setq mjtime(menucmd "M=$(edtime,$(getvar,date),YYYYMDhhmmssmsec)"));;取得系统时间到毫秒
(setq mjtjxgzcx1(strcat "F:\\编号内容\\" mjtime ".txt"))
;;;(setq mjlst(length keys2) mjl 0)
(if(= mjaa 1)
(progn
(if(/= mjstd 3);;判断要修改的是哪个对话框就打开哪个文本文件!
(setq mjtjxgzcx2(open mjtjxgzcx1 "w"))
;;;(setq mjtjxgzcx2(open mjxgzcx4-dcl "w"))
)
(write-line (vl-prin1-to-string (read (itoa DCL行数2))) mjtjxgzcx2);;把动态对话框的行数写到文本文件里
(write-line (vl-prin1-to-string (read txt2)) mjtjxgzcx2);;写入各个动态编辑框及下拉按钮控件的值
;;; (repeat mjlst;;把各个控件的key值写入文本文件(取到注释后就可以用了)
;;;(setq mjlst1 (nth mjl keys2))
;;;(write-line (vl-prin1-to-string (read mjlst1)) mjtjxgzcx2)
;;;(setq mjl (+ mjl 1))
;;; );;repeat
;;下面这部分写入的是各面墙的最后一个距离
(write-line (vl-prin1-to-string (read textx1)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read texty1)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read texts1)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read textz1)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read textx2)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read texty2)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read texts2)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read textz2)) mjtjxgzcx2)
(write-line (vl-prin1-to-string (read mjsjcd)) mjtjxgzcx2)
(close mjtjxgzcx2)
);;progn
);;if
)
(defun mjtjzcx();;编号控件组合(点击添加按钮执行此程序)
(setq mjtime(menucmd "M=$(edtime,$(getvar,date),YYYYMDhhmmssmsec)"));;取得系统时间到毫秒
(setq mjbh2(get_tile "mjtysj1"));;取得曲直按钮的值
(setq mjbh3(atoi(get_tile "mjtysj2")))
(setq mjbh4(get_tile "mjtysj3"))
(setq mjbh5(atoi(get_tile "mjtysj4")))
(setq mjbh6_1(list(strcat "全直" (nth mjbh3 mjbh-3) "全直角" (nth mjbh5 mjbh-5))));;这里的“全直”和“全直角”以后还要用mjbh2和mjbh4替换掉!因为现在只有一个对象所以不用判断就可以直接用
(if (/= mjbh6 nil)(setq mjbh6(append mjbh6_1 mjbh6))(setq mjbh6 mjbh6_1))
(tt1)
)
(defun mjsczcx();;点击“删除”按钮执行的子程序
(setq mjbh9 nil mjbh12 nil)
(setq mjbh7(atoi(get_tile "mjlbk")));;将取得的值转换为实数
(setq mjbh8(length mjbh6));;取得列表个数
(if (= mjbh7 0)
(setq mjbh6(cdr mjbh6));;如果选择的是列表里第一个则执行这句
(progn
(setq xgi1 0)
(repeat mjbh7
(setq mjbh10(nth xgi1 mjbh6));;提取列表的元素
(setq mjbh9(cons mjbh10 mjbh9));;将取得的元素结合成一个列表
(setq xgi1(+ xgi1 1))
);;while
(setq xgi2 (+ mjbh7 1))
(setq mjbh13(- mjbh8 mjbh7 1));;循环次数
(repeat mjbh13;;循环
(setq mjbh14(nth xgi2 mjbh6));;提取列表的元素
(setq mjbh12(cons mjbh14 mjbh12));;将取得的元素结合成一个列表
(setq xgi2(+ xgi2 1))
)
(setq mjbh6(append (reverse mjbh9) (reverse mjbh12)));;将两个列表倒序并结合成一个列表
(if(/= mjbh6 nil)
(progn
(start_list "mjlbk");;打开关键字为mjlbk的列表
(mapcar'add_list mjbh6);;依次向列表添加表项
(end_list);;结束当前列表控件的处理
);;progn
)
);;progn
)
)
(defun tt1()
;(if (/= (getstring "\n是否访问猫老师提供的免费Lisp在线视频教程?/") "n")
; (command "BROWSER" "http://www.youku.com/playlist_show/id_5180662.html")
;)
(if (not DCL行数2)(setq DCL行数2 1))
(cond ((= mjstd 2) (setq DCL行数2 1))
((= mjstd 3) (setq DCL行数2(car mjxgzcx8)))
);;cond
(cond ((= mjstd 2) (setq txt2 nil))
((= mjstd 3) (setq txt2(cadr mjxgzcx8)))
);;cond
(setq DCL运算符2 '("1下门" "1下窗" "1右门" "1右窗" "1上门" "1上窗" "1左门" "1左窗" "2下门" "2下窗" "2右门" "2右窗" "2上门" "2上窗" "2左门" "2左窗"))
(autolispcoder_load2)
(setq aa DCL行数2)
(princ "\n不死猫荣誉出品!QQ43797405")
(princ)
)
(defun autolispcoder_load2( / dcl_id2 Dialog_Return2 key Dcl_File2)
(vl-load-com)
;;;(if(/= mjstd 3);;判断要修改的是哪个对话框就打开哪个对话框!
(setq dcl_id2 (load_dialog (setq Dcl_File2 (Write_Dcl_autolispcoder2))));对话框加载
;;; (setq dcl_id2 (load_dialog mjxgzcx4-dcl))
;;;);;if
;;;(vl-file-delete Dcl_File2);加载后删除DCL文件
(setq Dialog_Return2 2)
(while (> Dialog_Return2 1) ;循环控制对话框是否结束
(new_dialog "autolispcoder2" dcl_id2);建立窗体
;-->-->-对话框初始化->-->--
(setq keys2 '("Command10" "Command20" "Text0" "accept"));列表全部控件名称
(setq i 1)
(repeat DCL行数2
(setq keys2 (append keys2 (list (strcat "Text0" (itoa (1- (* i 2)))) (strcat "Combo0" (itoa i)) (strcat "Text0" (itoa (* i 2))))))
(start_list (strcat "Combo0" (itoa i)));下拉列表 {"Combo1"} 初始化
(mapcar 'add_list DCL运算符2);添加列表项
(end_list)
(setq i (1+ i))
)
(foreach key keys2;全部控件的初始化
(if (eval (read (strcat key "_bak"))) (set_tile key (eval (read (strcat key "_bak")))));控件内容
(action_tile key "(Action_autolispcoder_Keys2 $key $value)");点击动作
)
(if(/= textx1 nil) (set_tile "Textx1" textx1));;判断各个墙的数据是否为空,如果不为空这赋予其值为上次输入的值
(if(/= texty1 nil) (set_tile "Texty1" texty1))
(if(/= texts1 nil) (set_tile "Texts1" texts1))
(if(/= textz1 nil) (set_tile "Textz1" textz1))
(if(/= textx2 nil) (set_tile "Textx2" textx2))
(if(/= texty2 nil) (set_tile "Texty2" texty2))
(if(/= texts2 nil) (set_tile "Texts2" texts2))
(if(/= textz2 nil) (set_tile "Textz2" textz2))
(if(/= mjsjcd nil) (set_tile "mjsjcd" mjsjcd) (set_tile "mjsjcd" "chang"));;判断单选按钮组是否为空,如果是这设置默认为长
;--<--<-对话框初始化完成-<--<--
(setq Dialog_Return2 (start_dialog));开启对话框(用户可见)
)
(unload_dialog dcl_id2);退出时卸载对话框
(if (= Dialog_Return2 -99)
(autolispcoder_load2)
)
(setq mjaa Dialog_Return2)
(if (= mjaa 1) (mjtjxgzcx));;
(princ);防止函数回显
)
(defun Action_autolispcoder_Keys2 (key value) ;全部控件的点击动作触发
(cond
;;; ((= key "accept") ;{确认按钮}
;;;
;;; (Get_autolispcoder_Data2)
;;; (done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
;;; )
;;; ((= key "cancel") ;{取消按钮}
;;;
;;; (done_dialog 0);对话框退出返回主函数 传递给Dialog_Return值为0
;;; )
((= key "Command10") ; {"增加一行"} (按钮)
(mj_quzhi)
(setq DCL行数2 (1+ DCL行数2))
(Get_autolispcoder_Data2)
(vl-file-delete Dcl_File2);加载后删除DCL文件
(done_dialog -99)
)
((= key "Command20") ; {"删除一行"} (按钮)
(mj_quzhi)
(Get_autolispcoder_Data2)
(vl-file-delete Dcl_File2);加载后删除DCL文件
(if (> DCL行数2 0)
(setq DCL行数2 (1- DCL行数2))
)
(done_dialog -99)
)
((= key "accept") ; 确定按钮
(setq txt2 "(")
(setq i 1)
(repeat DCL行数2
(setq txt2 (strcat
txt2
"(" (nth (read (get_tile (strcat "Combo0" (itoa i)))) DCL运算符2)
" " (get_tile (strcat "Text0" (itoa (1- (* i 2)))))
" " (get_tile (strcat "Text0" (itoa (* i 2))))
")"
))
(setq i (1+ i))
)
(mj_quzhi);;取得两矩形中上下左右墙的最后一个数据(子程序)
(setq txt2 (strcat txt2 ")"))
(set_tile "Text0" txt2)
(Get_autolispcoder_Data2)
;;; (qumenshujv);;拆分、判断、组合所取得的门、窗、墙数据(子程序)
(done_dialog 1);对话框退出返回主函数 传递给Dialog_Return值为1
)
((= key "Combo10") ; {} (下拉列表)
()
)
)
)
(defun mj_quzhi();;取得两矩形中上下左右墙的最后一个尺寸(如果没有门窗则为整面墙的尺寸)
(setq textx1(get_tile "Textx1"))
(setq texty1(get_tile "Texty1"))
(setq texts1(get_tile "Texts1"))
(setq textz1(get_tile "Textz1"))
(setq textx2(get_tile "Textx2"))
(setq texty2(get_tile "Texty2"))
(setq texts2(get_tile "Texts2"))
(setq textz2(get_tile "Textz2"))
(setq mjsjcd(get_tile "mjsjcd"))
)
(defun Get_autolispcoder_Data2( / key);临时生成Dcl文件 返回文件名
(foreach key keys2
(set (read (strcat key "_bak")) (get_tile key));每个控件都赋给一个变量 用于下次开启初始化
)
)
(defun Mydcl初始化2(DCL行数2 / DCLA2 dclB2 DCLC2)
(setq DCLA2 (list
"autolispcoder2:dialog"
"{"
" label = \"不死猫老师自动编码工具范例-多条件处理\";"
" :row"
" {"
" :button"
" {"
" key = \"Command10\" ;"
" label = \"增加一行\" ;"
" width = 22.95 ;"
" height = 4.275 ;"
" }"
" :button"
" {"
" key = \"Command20\" ;"
" label = \"删除一行\" ;"
" width = 24.15 ;"
" height = 4.275 ;"
" }"
" }"
))
(setq dclB2 nil)
(setq i 1)
(repeat DCL行数2
(setq dclB2 (append dclB2 (list
" :row"
" {"
" :edit_box"
" {"
(strcat " key = \"Text0" (itoa (- (* i 2) 1)) "\" ;")
" label = \"门或窗距\" ;"
" width = 13.35 ;"
" height = 0.675 ;"
" }"
" :popup_list"
" {"
(strcat " key = \"Combo0" (itoa i) "\" ;")
" width = 5;"
" height = 1.5 ;"
" }"
" :edit_box"
" {"
(strcat " key = \"Text0" (itoa (* i 2)) "\" ;")
" label = \"门或窗宽\" ;"
" width = 14.55 ;"
" height = 0.675 ;"
" }"
" }"
)
))
(setq i (1+ i))
)
(setq DCLC2 (list;;输入门或窗距和门或窗宽的对话框!如果某一面墙没有
" :row"
" {"
" :edit_box"
" {"
" key = \"Textx1\" ;"
" label = \"1下墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Texty1\" ;"
" label = \"1右墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Texts1\" ;"
" label = \"1上墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Textz1\" ;"
" label = \"1左墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" }"
" :row"
" {"
" :edit_box"
" {"
" key = \"Textx2\" ;"
" label = \"2下墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Texty2\" ;"
" label = \"2右墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Texts2\" ;"
" label = \"2上墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" :edit_box"
" {"
" key = \"Textz2\" ;"
" label = \"2左墙\" ;"
" width = 8.75 ;"
" height = 0.9375 ;"
" }"
" }"
" :boxed_radio_row";;单选按钮组
" {"
"key = \"mjsjcd\";"
" :radio_button"
" {"
"label=\"以短的为准&d\";key=\"duan\" ;"
" }"
" :radio_button"
" {"
"label=\"以长的为准&c\";key=\"chang\";"
" }"
" }"
"ok_only ;"
"}"
)
)
(append DCLA2 dclB2 DCLC2)
)
(defun Write_Dcl_autolispcoder2( / Dcl_File2 file2 str2)
(setq Dcl_File2 (vl-filename-mktemp nil nil ".Dcl"))
(setq file2 (open Dcl_File2 "w"))
(foreach str2 (Mydcl初始化2 DCL行数2)
(write-line str2 file2)
)
(close file2)
Dcl_File2
) mjtysj:dialog{
:column{label="幅面规格";//加框互锁行标签
:radio_row{
key="mjxjdq";
:radio_button{label="新建工程";key="mjxj";}//按钮A0
:radio_button{label="读取工程";key="mjdq";}//按钮A1
}
:row{
:boxed_column{
label="新建(&X)";
:edit_box{
key="mjxj1";
edit_limit=24;
}
:popup_list{
key="mjxj2";
}
}
:boxed_column{
label="读取(&D)";
:edit_box{
key="mjdq1";
edit_limit=24;
}
:popup_list{
key="mjdq2";
}
}
}
}
spacer_1;
label="编号";
:boxed_radio_row{
:popup_list
{label="曲直:";
// list="全直\n曲直\n全曲";
list="全直";
key= "mjtysj1";
}
:popup_list
{label="边数:";
list="4\n6\n8";
key= "mjtysj2";
}
:popup_list
{label="角度:";
// list="全部直角\n非全直角\n全非直角";
list="全直角";
key= "mjtysj3";
}
:popup_list
{label="形状:";
list="T型\nZ型\nU型";
key= "mjtysj4";
}
// :button{label="详细数据";key="mjtysj5";}
}
:row{
:boxed_column{
label="数据库编号";
:list_box{
key="mjlbk";
height=16;
}
}
:boxed_column{
label="已选编号";
:list_box{
key="mjlbk1";
height=16;
}
}
}
:boxed_radio_row{
:button{label="添加(&t)";key="mjtysj5";}
:button{label="修改(&x)";key="mjtysj6";}
:button{label="删除(&s)";key="mjtysj7";}
}
ok_cancel;
} 自己顶一下贴……就算没人帮忙顶起来有DCL的初学者应该也可以学习学习! 难道都没人对这个感兴趣...... 此贴经过自己的折磨已经差不多解决!不过还需要点时间补一下bug在此多谢 猫老师 的指点! 这个很不错!!!!
已经自己解决了 很好,想法不错 虽然不明白,努力学习中。。。,楼主辛苦,支持原创 要怎么才能把币收回来?
页:
[1]
2