Author Topic: To Know when user cancels the routine in Error Handling  (Read 2633 times)

0 Members and 1 Guest are viewing this topic.

Arun Raj

  • Guest
To Know when user cancels the routine in Error Handling
« on: July 24, 2004, 02:43:57 AM »

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
To Know when user cancels the routine in Error Handling
« Reply #1 on: July 24, 2004, 04:23:19 AM »
Lookup vl-catch-all-apply.

example:
returns nil or real
Code: [Select]

(defun MST-Getreal (msg / r)
  (if
    (and
      (= (type msg) 'STR)
      (not
        (vl-catch-all-error-p
          (setq r (vl-catch-all-apply 'getreal (list msg)))
          )
        ); not
      )
    r
    ); if
  ); defun
TheSwamp.org  (serving the CAD community since 2003)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
To Know when user cancels the routine in Error Handling
« Reply #2 on: July 24, 2004, 08:05:38 AM »
This is the way I approach it, I borrowed this code from stig
some time back.
You will notice at the end of the routine *error* ""
this flags the normal exit and the error routine is used to reset
variables changed during start up.
Also note "console break" "Function cancelled" "quit / exit abort"
any of those messages are caused by the user pressing ESCAPE.

Code: [Select]
(defun c:mainroutine (/ *error* useror useros usercmd)
  ;; error function & Routine Exit
  (defun *error* (msg)
    (if
      (not
(member
 msg
 '("console break" "Function cancelled" "quit / exit abort" "")
)
      )
       (princ (strcat "\nError: " msg))
    ) ; endif

    ;;reset all variables here
    (setvar "orthomode" useror)
    (setvar "osmode" useros)
    (setvar "CMDECHO" usercmd)
  ) ;end error function

;;;  =================================================================
;;;                       Main Routine
;;;  =================================================================
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))
  (setq useror "orthomode")

  ;; ****************************************
  ;;       Your code goes here
  ;; ****************************************

 
  ;; End of main routine and exit
  (*error* "") ; call error routine to reset vars
  (princ)  ; exit quietly
) ; end defun
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
To Know when user cancels the routine in Error Handling
« Reply #3 on: July 24, 2004, 11:22:43 AM »
Did you ask them? ...That's what i do.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
To Know when user cancels the routine in Error Handling
« Reply #4 on: July 24, 2004, 04:44:13 PM »
LOL