Author Topic: separate namespace - vlx error handling  (Read 1450 times)

0 Members and 1 Guest are viewing this topic.

neyton

  • Newt
  • Posts: 68
separate namespace - vlx error handling
« on: January 14, 2016, 08:09:46 PM »
If you test the following program without compiling it works.
But if compiling with separate namespace VLX, he does not behave as it should.
The TEST function should show an error message (division by zero)
Did I miss something?


Code - Lisp: [Select]
  1.  
  2.  
  3. (defun tbn:error-init (sys / tmp ss cmd)
  4.   (*push-error-using-command*)
  5.   (setq tbn:olderr     *error*
  6.         *error*        (lambda (s)               
  7.                          (if (/= s "Function cancelled")
  8.                            (prompt (strcat "\nBomb!! Error: " s)))
  9.                          (while (= (getvar "CMDACTIVE") 1)
  10.                            (command))
  11.                          (eval tbn:error_exe)
  12.                          (tbn:error-restore))
  13.         tbn:error_exe  (cadr sys)
  14.         sys            (car sys)
  15.         tbn:sysvars    nil
  16.         tbn:error-undo (getvar "undoctl")
  17.         ss             (ssgetfirst)
  18.         cmd           (getvar "cmdecho"))
  19.  
  20.   (setvar "cmdecho" 0)
  21.   (cond ((= 2 (logand tbn:error-undo 2))
  22.          (command "_.undo" "_control" "_all"
  23.                   "_.undo" "_auto" "_off"))
  24.         ((/= 1 (logand tbn:error-undo 1))
  25.          (command "_.undo" "_all"
  26.                   "_.undo" "_auto" "_off")))
  27.   (command "_.UNDO" "_group")
  28.   (setvar "cmdecho" cmd)
  29.  
  30.   (repeat (/ (length sys) 2)
  31.     (setq tmp         (car sys)
  32.           tbn:sysvars (cons (list tmp (getvar tmp))
  33.                             tbn:sysvars)
  34.           tmp         (setvar tmp (cadr sys))
  35.           sys         (cddr sys)))
  36.   (sssetfirst (car ss) (cadr ss)))
  37.  
  38.  
  39. (defun tbn:error-restore (/ cmd x)
  40.  
  41.   (foreach x tbn:sysvars (setvar (car x) (cadr x)))
  42.   (redraw)
  43.   (setq cmd (getvar "cmdecho"))
  44.   (setvar "cmdecho" 0)
  45.   (command "_.UNDO" "_e")
  46.   (cond ((/= 1 (logand tbn:error-undo 1))
  47.          (command "_.undo" "_control" "_none"))
  48.         ((= 2 (logand tbn:error-undo 2))
  49.          (command "_.undo" "_control" "_one")))
  50.   (setvar "cmdecho" cmd)
  51.  
  52.   (setq *error* tbn:olderr)
  53.   (*pop-error-mode*)
  54.   (princ))
  55.  
  56.  
  57.  
  58. (defun c:teste (/ ss a b)
  59.  
  60.   (tbn:error-init '(("cmdecho" 0 "osmode" 0) nil))
  61.   (setq a (getpoint)
  62.         b (getpoint a)
  63.   )
  64.   (command "line" a b "")
  65.  
  66.   (setq a (getpoint)
  67.         b (getpoint a)
  68.   )
  69.   (command "line" a b "")
  70.   (/ 1 0)
  71.   (setq a (getpoint)
  72.         b (getpoint a)
  73.   )
  74.   (command "line" a b "")
  75.  
  76.   (setq ss (ssget))
  77.   (alert (itoa (sslength ss)))
  78.  
  79.   (tbn:error-restore)
  80. )
  81.  
  82.  
  83.  
  84.  
  85.  
Visit my website: http://tbn2.blogspot.com