yyz123121 发表于 2020-10-6 21:08:57

如何在面板里增加当前时间,以及增加其他程序?

请教一下,怎么在这个面板下边的帮助按钮旁边增加一个按钮,点击这个按钮就打开指定位置的其它vlx文件?
我加入下边这句之后,可以用快捷命令启动指定的程序,但是点击按钮没反应,按钮那个地方应该怎么写?
(defun c:***() (if (null c:***) (load "D:/***.VLX"))(c:***));打开其它程序

这个地方应该怎么写,才能让点击按钮也能够启动指定的程序?
   ":button{key = \"c:***\";label = \"批量打印\";}\n"

另一个问题,我加载了一个外部程序之后,加载第二个的话,
提示说“出现硬错误 ***
已达内部堆栈限制 (模拟)”

最后我想在左下角增加时间,应该怎么写,能说一下吗。
谢谢了

下边是在论坛里找到的面板源码:
(defun Dcl-ButtonM (titl buttons flag / a b c)
   (defun strsplist (str / i)
   (if (setq i (vl-string-search " " str))
       (list (substr str 1 i)
                                 (vl-string-trim " " (substr str (+ 2 i)))
       )
               )
   )
   (defun makedcl (str_lst / fileID dclHandle)
   (setq
                         dclfile (vl-filename-mktemp nil nil ".dcl")
                         fileID(open dclfile "w")
   )
   (cond
                         ((= (type str_lst) 'str)
                                 (write-line str_lst fileID)
                         )
                         ((= (type str_lst) 'list)
                                 (foreach n str_lst (write-line n fileID))
                         )
               )
               (close fileID)
               (setq dclHandle (load_dialog dclfile))
         )
         (setq
               b (if flag
                                 ":column{label = \""
                                 (strcat
                                 ":spacer{ wide=1; fixed_width=true;} \n"
                                 ":spacer{ wide=1; fixed_width=true;} \n"
                                 ":row{label = \""
                                 )
                  )
               c (if flag
                                 ":row{label = \""
                                 ":column{label = \""
                         )
               d '("ESC")
               a (strcat (vl-string-translate
                                                               "$~"
                                                               "AB"
                                                               (vl-filename-base (vl-filename-mktemp))
                                                         )
                                 ":dialog{label=\""
                                 titl
                                 "\";\n"
                                 b
                                 "\";\n"
                         )
   )
   (foreach x buttons
   (if (listp x)
       (progn
         (setq a (strcat a c (car x) "\";\n"))
         (foreach y (last x)
         (setq
                                                 b (strsplist y)
                                                 a (if b
                                                               (strcat a
                                                                         ":button {key =\""
                                                                         (car b)
                                                                         "\";label=\""
                                                                         (last b)
                                                                         "\";}\n"
                                                               )
                                                               (strcat a "spacer_0;\n")
                                                         )
                                                 d (if (/= (car b) nil)
                                                               (cons (car b) d)
                                                               d
                                                         )
         )
         )
         (setq a (strcat a "}\n"))
       )
       (setq a (strcat a "spacer_0;\n"))
   )
   )
         (setq
               d    (cdr (REVERSE d))
               a    (strcat a
                                          "}"
                                          ":text{key=\"str\";label=\"文字\";}"
                                          ":row{"
                                          ":spacer { width = 60; } "
                                        ":button{key = \"c:***\";label = \"批量打印\";}\n"
                                          ":button{key = \"HLP\";label = \"帮助\";}\n"
                                          ":button{key=\"ESC\";label=\"取消\";is_cancel = true;}}}"
                                  )
               dcl(makedcl a)
               lst1 '()
               i    1
   )
   (foreach key d
   (setq
                         tx   (strcat "(action_tile \""
                                                key
                                                "\"\"(done_dialog "
                                                (itoa i)
                                                ")\")"
                                          )
                         lst1 (cons tx lst1)
                         i    (1+ i)
   )
   )
   (new_dialog (substr a 1 8) dcl)
   (action_tile "ESC" "(done_dialog 0)")
   (action_tile "HLP" "(alert\"帮助\")")
   (eval (read (strcat "(progn" (apply 'strcat lst1) ")")))
   (setq ctl (start_dialog))
   (UNLOAD_DIALOG dcl)
   (vl-file-delete dclfile)
         (if (/= ctl 0)
   (eval (read (strcat "(c:" (nth (- ctl 1) d) ")")))
   )
)
(defun c:tt (/ lst)
   (setq      lst '(
                         ("命令"
                                 ("0 改为0层"
                         )
                         ("视口"
                                 ("ZZ 视口比例 "
                         )

                )
   )      
(Dcl-ButtonM "xx工具箱 " lst nil)
         (princ)
)

wzg356 发表于 2020-10-7 16:01:21

面板示例,里面有时间显示
根据这个原理自己试验修改
(defun c:tt8( / f s dcl_id chk)
    (setq DCL (vl-filename-mktemp nil nil ".Dcl"))
    (setq f (open dcl "w"))
    (foreach s '(
"Form1:dialog"
"{label = \"面板示例\";"
"    :column"
"    {"
"      :button{ key = \"key1\" ;label = \"按钮1\" ;}"
"      :button{ key = \"key2\" ;label = \"按钮2\" ;}"
"      :button{ key = \"key3\" ;label = \"按钮3\" ;}"
;可以继续增加,照上面button例子
"      :text{ key = \"xssj\" ;label = \"启动时间\" ;}"
"    }"
":button{key=\"cancel\";label=\" 关闭 \";is_cancel = true;}"
"}"
    )
    (write-line s f))
    (close f)
    (setq dcl_id (load_dialog DCL))
    (vl-file-delete Dcl)
    (new_dialog "Form1" dcl_id)
    (set_tile "xssj" (rtos (getvar "CDATE"))) ;当前时间
    (Action_Tile "key1" "(done_dialog 1)")
    (Action_Tile "key2" "(done_dialog 2)")
    (Action_Tile "key3" "(alert \"功能未开发\")") ;按面板对应继续写
    (Action_Tile "cancel" "(done_dialog 0)")
    (setq chk (start_dialog))
    (unload_dialog dcl_id)
    (cond
          ((= chk 1)(key1));启动小程序key1
          ((= chk 2)(alert "功能2"))
          ; ----继续填写功能          
        );可以看看结果
)
(defun key1 ()
        (alert "功能1")       
)

yyz123121 发表于 2020-10-8 13:06:12

wzg356 发表于 2020-10-7 16:01
面板示例,里面有时间显示
根据这个原理自己试验修改
(defun c:tt8( / f s dcl_id chk)


没看懂,这个显示的时间不完整,
我从论坛里看时间显示用这句
(menucmd "m=$(edtime,$(getvar,date),YYYY年M月D日 HH:MM:SS DDD)")
但是不知道应该加在哪

wzg356 发表于 2020-10-8 14:29:46


(set_tile "xssj" (rtos (getvar "CDATE"))) ;当前时间
换成
(set_tile "xssj" (menucmd "m=$(edtime,$(getvar,date),YYYY年M月D日 HH:MM:SS DDD)"))

zj20190405 发表于 2020-10-11 09:07:56

wzg356 发表于 2020-10-8 14:29
(set_tile "xssj" (rtos (getvar "CDATE"))) ;当前时间
换成
(set_tile "xssj" (menucmd "m=$(edtime ...
大佬,时间加到面板示例后面,如何修改

注册 发表于 2022-12-9 07:47:18

wzg356 发表于 2020-10-8 14:29
(set_tile "xssj" (rtos (getvar "CDATE"))) ;当前时间
换成
(set_tile "xssj" (menucmd "m=$(edtime ...

可用----------------------------
页: [1]
查看完整版本: 如何在面板里增加当前时间,以及增加其他程序?