我正在使用一个相当简单的DCL应用程序,它是从Jeffery P.Sanders网站教程中获得的:
- (defun GetUserInput ()
- (setq server_path "//a_very_long_novell_path/")
- ;;;--- Try to load the DCL file from disk into memory
- (if(not(setq dcl_id (load_dialog (strcat server_path "MyDCLFile.dcl"))))
- (progn
- (alert "The DCL file could not be loaded.")
- (exit)
- )
- ;;;--- Else, the DCL file was loaded into memory
- (progn
- ;;;--- Try to load the definition inside the DCL file
- (if (not (new_dialog "MyDCL" dcl_id))
- (progn
- (alert "The definition could not be found inside the DCL file")
- (exit)
- )
- ;;;--- Else, the definition was loaded, we are ready to roll
- (progn
- ;;;--- If an action event occurs, do this function
- (action_tile "cancel" "(done_dialog 1)")
- (action_tile "accept" "(saveVars)(done_dialog 2)")
- ;;;--- Display the dialog box
- (setq ddiag(start_dialog))
- ;;;--- If the cancel button was pressed - display message
- (if (= ddiag 1)
- (princ "\n \n ...EXAMPLE Cancelled. \n ")
- )
- ;;;--- If the "Okay" button was pressed
- (if (= ddiag 2)
- (princ "\n \n ...Example Complete!")
- )
- )
- )
- )
- )
- ;;;--- Suppress the last echo for a clean exit
- (princ)
- ); end GetUserInput function
- (defun Popup ( title msg flags / wsh )
- (vl-catch-all-apply
- (function
- (lambda nil
- (setq wsh (vlax-create-object "WScript.Shell"))
- (setq res (vlax-invoke-method wsh 'popup msg 0 title flags))
- )
- )
- )
- (if wsh (vlax-release-object wsh))
- res
- )
我想做的是在退出此例程之前验证用户的输入。它需要两个输入,一个跨度和一个宽度。我正在检查它们是否在有限范围内,然后它进入程序的另一部分。但是如果用户输入了无效的内容,我想警告他们。。。我用李·Mac的弹出程序来做这件事,但一旦他们在收到错误警告后按OK,我希望程序DCL重置并再次询问用户,并不断询问用户输入,直到他们得到正确的结果。有谁能就如何最好地处理这个问题提出一些建议吗?
我让它工作并检查有效输入,但现在它只是退出。我正在寻找一种方法,以不断重复输入,直到用户得到它的权利。
再次证明,这很难,但确实能够编写复杂的代码来进行计算和绘制图形。最困难的部分是防止用户扔进垃圾桶,如果他们出错,再给他们一次机会。 |