How Does this Code Work: Error Handling

Discussion in 'AutoCAD' started by bcbii, Oct 1, 2004.

  1. bcbii

    bcbii Guest

    Hi,

    (defun c:90elbow (/ inspoint px py part1 part2 *Error*)
    (setq *Error* Error)
    ;My really long code;
    )

    (defun Error (Msg)
    (cond
    ((member (strcase Msg T) '("console break" "function cancelled" "quit /
    exit abort")))
    ((princ (strcat "\nERROR: " Msg))))
    (princ)
    )

    I was wondering, if there is somebody that would be kind enough to explain
    to me how this error code works? Specifically I am at a loss to describe
    the origins of Msg, as the 3 instances of it above are the only ones in my
    code. I also can not figure out how *Error* is related to the Error
    function?

    Thank you
     
    bcbii, Oct 1, 2004
    #1
  2. bcbii

    C Witt Guest

    *Error* - is the "command" cad calls up when there is a problem.. so by
    changing were it is directed (the setq *error* bit) you are telling cad
    to call up your error lisp when there is a problem

    msg - is the message that cad supplies (the description of what
    happened). it's not somthing you want to set.

    HTH
     
    C Witt, Oct 2, 2004
    #2
  3. bcbii

    bcbii Guest

    Cool, thank you for clearing that up for me.
     
    bcbii, Oct 2, 2004
    #3
  4. Jim,

    That process was relevant for R14 and earlier, but unneeded in A2k and
    above. Localizing *error* before redefining it is all you need to do now.

    --
    R. Robert Bell


    Check-out the attached LSP file. It contains a command that show the proper
    use of the *error* function and most importantly how to set it back. You
    most likely don't want to "permanently" change this function, although I see
    you have localized the *error* function.
     
    R. Robert Bell, Oct 4, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.