Code Red > AutoLISP (Vanilla / Visual)
unable the escape key..
Andrea:
hi all....
I work to make a little function detection...
--- Code: ---(defun INGcommand( / g)
(while (setq g (strcase (getstring "INGcommand: ")))
(progn
(if (vl-string-search "ING" g)(alert "You have entered a ING command"))
(if (eq g "COMMAND")(exit))
(if (and
(not (vl-string-search "ING" g))
(not (eq g "COMMAND"))
)
(alert "Invalid ING command.\n Type \"Command\" to return to AutoCAd command.")
)
)
(INGcommand)
)
)
(INGcommand)
--- End code ---
It work great....since press the ESCAPE key.
any suggestion ?
kpblc:
You can try to use (vl-catch-all-apply) function or check the errno system variable value.
Kerry:
Andrea,
you could modify or use something like this ...
--- Code: ---;;;--------------------------------------------------------------------------
;;;--------------------------------------------------------------------------
;| #lib.
kb:getString (<Promptmsg><Default><InitBit><AllowSpaces>)
Revised Library : kwb 20051031
20051101 kwb : ESC test added.
Build 2.0 :
(SETQ tmpVal (kb:getString "Lot Description" nil (+ 1 ) T))
(SETQ tmpVal (kb:getString "Name" "Me" (+ 1 ) Nil))
(SETQ tmpVal (kb:getString nil nil nil Nil))
|;
(DEFUN kb:getString (Promptmsg ; The prompt string.
Default ; Value to return if response is <enter>
InitBit ; Initget bit
AllowSpaces ; spaces Flag < T or nil )
;
/ returnvalue)
;;------------------------------
(OR InitBit (SETQ InitBit 0))
;;------------------------------
(SETQ Promptmsg (STRCAT "\n"
(COND (Promptmsg)
("Specify String Value")
)
)
)
;;------------------------------
(IF (AND Default (= (TYPE Default) 'str) (/= Default ""))
(PROGN
(SETQ Promptmsg (STRCAT "\n" Promptmsg " << " Default " >>: "))
(IF (VL-CATCH-ALL-ERROR-P
(SETQ returnvalue (VL-CATCH-ALL-APPLY
'GETSTRING
(LIST AllowSpaces Promptmsg)
)
)
)
;; ESC was pressed.
(SETQ ReturnValue nil
Default nil
)
)
(SETQ returnvalue (IF (= returnvalue "")
Default
returnvalue
)
)
)
;; Else no default, so don't accept ENTER or SPACEBAR
;;
(PROGN (SETQ Promptmsg (STRCAT "\n" Promptmsg ": "))
(IF (= InitBit 1)
(WHILE (= ""
(SETQ returnvalue (VL-CATCH-ALL-APPLY
'GETSTRING
(LIST AllowSpaces Promptmsg)
)
)
)
)
;;
(SETQ returnvalue
(VL-CATCH-ALL-APPLY 'GETSTRING
(LIST AllowSpaces Promptmsg)
)
)
)
(IF (VL-CATCH-ALL-ERROR-P returnvalue)
;; ESC was pressed.
(SETQ ReturnValue nil)
)
)
)
;;------------------------------
returnvalue
)
;;;--------------------------------------------------------------------------
;;;--------------------------------------------------------------------------
--- End code ---
MP:
<warning, I just woke up>
Abused from this post --
--- Code: ---(defun Evaluate ( expression / result )
(vl-catch-all-apply
'(lambda ( )
(setq result
(eval expression)
)
)
)
result
)
--- End code ---
Possible useage --
--- Code: ---(defun INGcommand ( / g done )
(while
(and
(not done)
(setq g (Evaluate '(strcase (getstring "INGCommand: "))))
)
(cond
( (eq g "COMMAND")
(setq done t)
)
( (vl-string-search "ING" g)
(alert "You have entered a ING command")
)
( t
(alert
(strcat
"Invalid ING command.\n"
"Type \"Command\" to return"
"to AutoCAD command."
)
)
)
)
)
(princ)
)
--- End code ---
Patrick_35:
Hi
--- Code: ---(defun INGcommand(/ g)
(while (setq g (vl-catch-all-apply 'getstring (list "\nINGcommand: ")))
(if (not (vl-catch-all-error-p g))
(progn
(if (vl-string-search "ING" g)(alert "You have entered a ING command"))
(if (eq g "COMMAND")(exit))
(if (and
(not (vl-string-search "ING" g))
(not (eq g "COMMAND")))
(alert "Invalid ING command.\n Type \"Command\" to return to AutoCAd command.")
)
)
(if (member (vl-catch-all-error-message a) (list "Fonction annulée" "Function cancelled"))
(setq g T)
)
)
)
)
(INGcommand)
--- End code ---
@+
Navigation
[0] Message Index
[#] Next page
Go to full version