wwUtils::SafeEval

Evaluates a FoxPro expression without blowing up by wrapping the EVALUATE() operation into an internal TRY/CATCH block.

o.SafeEval(lcEvalString,lvErrorResult)

Parameters

lcEvalString
String to evaluate - same value you would pass to EVALUATE()

lvErrorDisplay
The value to return when an error occurs Pass the special value** ERRORMESSAGE** to return the error message

Remarks

You cannot pass expressions that contain local variables or the THIS pointer since they will not be in scope in the executing wrapper function.

Example

<<code lang="VFP">>*** Execute 2 + 2 on Error -1 would be returned
lnResult = SafeEval("2+2",-1)

*** return the error message in lnResult
lnResult = SafeEval("2+2+A","ERRORMESSAGE")

IF VARTYPE(lnResult) = "C"
   ? lnResult && Error Message
ENDIF
<</code>>

See also:

Class wwUtils

© West Wind Technologies, 1996-2018 • Updated: 01/08/16
Comment or report problem with topic