Eval — Processes a string of text containing Biferno code
string Eval(text, resume);
string text;
boolean resume;
The Eval function processes a string of text containing Biferno code. We can write:
textToEval = "a = 3" Eval(textToEval) $a
line 3 of the example will print the value of the variable a, which is 3. The a variable has been defined and assigned the value 3 when the text passed to the Eval function was processed.
Notice that the textToEval string does not start with the "<?" characters. This is because the Eval implicitly assumes a "<?" tag before processing the text. If the textToEval string contains plain text, the text would have to be prefixed with the "?>" characters. An example is:
textToEval = "a = 3?><b>Hello Word</b>" result = Eval(textToEval) $result
Notice that this behavior is different from the include behavior. In an included file, before writing Biferno code, the "<?" must be explicitly used.
The last example also shows the meaning of the return variable of the function, which contains the entire text sent as output during execution. The first example generated no output, and the function returned the empty string. In the second example the result string contains the text: "<b>Hello Word</b>".
Parameters
the text to process
specifies the resum mode (see note)
What happens if the text passed to the Eval function (textToEval string) generates an error?
In this case the value of the third parameter (resume, left to its default value, false, in the previous examples) is crucial. If an error is generated the following applies:
resume is false: we can control if Eval will interrupt our script using the error.Resume function in the textToEval string with the usual error handling rules. Notice that some errors will interrupt code execution even if error.Resume has been called, as e.g. the Err_BadSyntax error. In any case, the code line after the call to the Eval function the global variable err will contain the code of the generated error.
resume is true: the Eval function will interrupt the execution of the text contained in textToEval according to the error handling rules, but, instead of interrupting the execution of the calling script upon an error, will return the name of the generated error in the return string. In any case, on the code line after the call to the Eval function the global variable err will contain the code of the generated error.