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

*** 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

See also:

Class wwUtils

© West Wind Technologies, 2004-2017 • Updated: 05/27/11
Comment or report problem with topic