Eval(), Getlastruncompileerror() – BrightSign BrightScript 3.0 Reference Manual User Manual
Page 56

51
Eval()
Eval(code_snippet As String) As Dynamic
This function runs the passed code snippet in the context of the current function. The function compiles the snippet, then
executes the byte-code. If the code compiles and runs successfully, it will return zero. If the code compiles successfully,
but encounters a runtime error, it will return an integer indicating the error code (using the same codes as the
GetLastRunRuntimeError() function). If compilation fails, it will return an roList object; the roList structure is identical
to that of the
GetLastRunCompileError() function.
The
Eval() function can be useful in two cases:
•
When you need to dynamically generate code at runtime.
•
When you need to execute a statement that could result in a runtime error, but you don’t want code execution to
stop.
Example:
PRINT Eval("1/0") ‘Returns a divide by zero error.
GetLastRunCompileError()
GetLastRunCompileError() As roList
This function returns an roList object containing compile errors (or Invalid if no errors occurred). Each roList entry is an
roAssociativeArray object containing the following keys:
•
ERRSTR: The compile error type (as String)
•
FILESPEC: The file URI of the script containing the error (as String)
•
ERRNO: The error number (as Integer)
•
LINENO: The line number where the error occurs (as Integer)