Author Topic: I'm tired of alert boxes interupting my scripts  (Read 3321 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
I'm tired of alert boxes interupting my scripts
« on: March 20, 2011, 12:10:40 AM »
So I created the following and am looking for feedback/suggestions.  The logging routines are fairly straight foreward, so I haven't included them here:

Procedures that have been redefined are:
Alert
Princ

Implementation:
Just prior to running your script add this file to your appload startup suite, and load it.

Run your script:
All messages that would have gone to alert boxes will instead be sent to the command line
and to the error log (via WriteToErrorLog loaded from Logging.lsp).  All messages that
would be sent to the command line via princ will also be sent to the the action log via
WriteToActionLog, again from logging.lsp.  Included with the information sent to the logs
is the names of all active commands at the time the entry is logged.

After running your script:
To restore normal behavior of Alert and Princ, run "RestoreAlerts" at the command prompt.
Perhaps do this as the last line in your script.



Code: [Select]
(if (and OldAlert (= 'USUBR (type alert)))
  nil
  (setq
    OldAlert alert
    OldPrinc princ
  )
)


(pragma '((unprotect-assign alert)))
(pragma '((unprotect-assign princ)))


(defun alert (msg)
  (if writetoerrorlog
    nil
    (load "logging")
  )
  (writetoerrorlog msg (getvar "cmdnames"))
  (oldprinc msg)
  (oldprinc)
)

(defun Princ (msg)
  (writetoactionlog (strcat (getvar "cmdnames") "|" msg))
  (oldprinc msg)
  (oldprinc)
)
(pragma '((protect-assign alert)))
(pragma '((protect-assign princ)))

(defun c:RestoreAlerts ()
  (pragma '((unprotect-assign alert)))
  (pragma '((unprotect-assign princ)))
  (setq
    alert OldAlert
    princ OldPrinc
  )
  (pragma '((protect-assign alert)))
  (pragma '((protect-assign princ)))
  (princ)
)


(progn
  (princ
    "\nLoading AlertToLog will send all alert messages to the error log."
  )
  (princ
    "\nRun \"RestoreAlerts\" to restore normal alert behavior."
  )
  (princ)
)

Crank

  • Water Moccasin
  • Posts: 1503
Re: I'm tired of alert boxes interupting my scripts
« Reply #1 on: March 20, 2011, 05:42:39 AM »
Very clever. :kewl:

Perhaps it could be a bit shorter if you set QAFLAGS to 4 -(No Alert boxes displayed).
Vault Professional 2023     +     AEC Collection

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: I'm tired of alert boxes interupting my scripts
« Reply #2 on: March 20, 2011, 06:10:28 AM »

Quote
set QAFLAGS to 4

I was expecting to see that too.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

mkweaver

  • Bull Frog
  • Posts: 352
Re: I'm tired of alert boxes interupting my scripts
« Reply #3 on: March 20, 2011, 10:31:02 AM »
Very clever. :kewl:

Perhaps it could be a bit shorter if you set QAFLAGS to 4 -(No Alert boxes displayed).
Blast!  Where did that come from?

Now I've got to decide if the logging is worth keeping the routine :|

danallen

  • Guest
Re: I'm tired of alert boxes interupting my scripts
« Reply #4 on: March 21, 2011, 05:01:45 PM »
For our routines I changed alerts to doslib's dos_msgbox which has an option to close after specified number of seconds.