Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>expr_error(name, line, info, model, _1, _2, _3) expression error</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Expr_error(name, line, info, model, _1, _2, _3)    Expression error

   Expression errors can occur whenever an expression is evaluated.
   Typically, these include type mismatch and divide by zero errors.


Info messages: Type mismatch
               Subscript range
               Zero divide
               Expression error

Model:         The model contains the erroneous expression as a
               character string with the operand parameters in place of
               the expression values.  The operand parameters "_1,"
               "_2," and "_3" themselves contain the actual operand
               values.

               For example, executing the following erroneous SUBSTR()
               expression:

                    ? SUBSTR("abc", 1, "2")

               executes Expr_error() with model containing
               "SUBSTR(_1,_2,_3)," _1 containing "abc," _2 containing 1,
               and "_3" containing "2."

Recovery:      RETURN <exp> passes a new value back to the point of
               error within the expression evaluation and execution
               continues.


------------------------- Example -- Errorsys.prg ----------------------------

   FUNCTION expr_error
   PARAM name, line, info, model, _1, _2, _3

   SET DEVICE TO SCREEN
   @ 0, 0
   @ 0, 0 SAY "Proc " + M->name + " line " + LTRIM(STR(M->line)) +;
            ", " + M->info

   QUIT

   RETURN .F.


------------------------- Example -- Alterror.prg -----------------------------

   FUNCTION expr_error
   PARAM name, line, info, model, _1, _2, _3
   PRIVATE result, sample

   IF M->info = "zero divide"
      IF "%" $ M->model
         RETURN M->_1
      ELSE
         RETURN 0
      END
   END

   ALTD(2)

   IF TYPE("M->result") != "U"
      RETURN M->result
   END


   SET DEVICE TO SCREEN
   @ 0, 0

   IF info = "type mismatch"
      M->sample = M->model
      M->sample = strtran(M->sample, "_1", type("M->_1"))
      M->sample = strtran(M->sample, "_2", type("M->_2"))
      M->sample = strtran(M->sample, "_3", type("M->_3"))

      @ 0, 0 SAY "Proc " + M->name + " line " + LTRIM(STR(M->line)) + ", " +;
               M->info + ": " + M->sample

   ELSE
      @ 0, 0 SAY "Proc " + M->name + " line " + LTRIM(STR(M->line)) + ", " +;
               M->info

   END

   BREAK

   RETURN .T.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson