Ahmeds 发表于 2022-7-6 07:05:02

在DCL中可能吗???

当我的DCL弹出/加载时,是否可以使其聚焦,以便用户在输入所需的正确代码/字符串之前无法工作。。
如果字符串错误,它会发出警报/说“无效键”,但在用户给出正确代码之前,它会一直保持加载和聚焦状态,如果用户取消了它,程序会退出加载其他LISP。
 
附:请参阅我随附的图片。

pBe 发表于 2022-7-6 07:14:01

我以前做过类似的事情,但出于对我的爱,我找不到代码。我会再挖一些,也许我会把它藏在一个叫做“安全”的文件夹里,而不是把整件事都写一遍

MSasu 发表于 2022-7-6 07:21:49

您可以对与“确定”按钮相关的事件执行此类验证:
(defun TestUserInput()
(if (/= (get_tile "MyInputBox")
      MySecretKeyString)
(progn
(set_tile"MyInputBox" "Invalid key, please try again!")
(mode_tile "MyInputBox" 2)
)
(done_dialog 1)
)
)

(action_tile "accept" "(TestUserInput)")
(action_tile "cancel" "(done_dialog 0)")

(if (= (getvar "DIASTAT") 1)
;run the code
;exit
)

Ahmeds 发表于 2022-7-6 07:27:42

 
希望你能尽快找到,我很乐意等待。别担心。。
 
MSasu,谢谢。。我下班后再试试。

pBe 发表于 2022-7-6 07:37:03

 
我不得不为您重新编写一个示例代码[原因:我把文件藏得很好,我自己找不到它]
 
(defun C:TEST(/ dcl_id)
   (setq dcl_id (load_dialog "ErrorTest.dcl"))
   (if (not (new_dialog "ErrorTest" dcl_id))
         (exit)
         )                           
   (mode_tile "ValidNumber" 2)
   (action_tile "accept" "(validate)")
   (action_tile "cancel" "(done_dialog 0)")
   (start_dialog)
   (unload_dialog dcl_id)
   (princ)
   )                                 
-----------------------
(defun validate()
(if (not (eq (get_tile "ValidNumber") "12577787-12FF0023-188330"))
   (progn
         (set_tile "error" "Invalid License key")
         (mode_tile "ValidNumber" 2))
         (done_dialog)
         )                  
         )                     

 

ErrorTest : dialog

{label = "License Verification";
: boxed_column {
: text { label = "Enter Valid License Key";
alignment = centered;}
: edit_box{ key = "ValidNumber";}
: row { alignment = centered;
: button { key = "accept";
label = "Accept";
is_default = true;
}       
: button { key = "cancel";
label = "cancel";
}               
}
: errtile {alignment = centered;}
}
}


 
编辑:更新DCL,无论如何这是一个重要的想法

Tharwat 发表于 2022-7-6 07:42:44

Pbe,很好的DCL对话框,您添加了取消按钮actione\u互动程序,没有DCL文件中的相关代码。
 
一个问题。你把DCL文件的名字写颠倒了。
 

(load_dialog "errortest.dcl")

pBe 发表于 2022-7-6 07:54:14

 
我想我更新了Tharwat代码
 
但它很酷,只要保存的DCL文件与load\u对话框表达式上写的文件同名
 
干杯

Ahmeds 发表于 2022-7-6 08:00:41

谢谢大家。。特别是为了pBe的努力。

pBe 发表于 2022-7-6 08:11:40

 
很高兴你找到了它的好用途。
 
如果你需要更多帮助,就喊一声
 
干杯,艾哈迈德
页: [1]
查看完整版本: 在DCL中可能吗???