EVAL Function
Description
The EVAL function compiles and executes the specified R/BASIC source code directly at TCL or within. To execute a compiled R/BASIC program from TCL, use the RUN command.
Syntax
EVAL code
Parameters
The function has the following parameters:
Parameter | Description | |
---|---|---|
code | Any R/BASIC source code. Because the source code does not go through a full pre-processing step, you cannot use $INSERT or DECLARE statements in the code. Multiple lines are delimited by semicolons or @fm. | |
Returns
Code can be a full program(@fm delimited) including parameter definitions. However, no parameters will be passed to it. If code has a first line of "FUNCTION whatever" it will be called as a function, EVAL will return the result. If code has a first line of "SUBROUTINE whatever" it will be called as a subroutine, EVAL will return null. If neither subroutine nor function, EVAL will add a header SUBROUTINE EVAL(void) to the code. EVAL will compare the code to the last one used. If it is the same and if it is still in the program stack then EVAL will simply call the already compiled program. If the source is different or if it was removed by a garbacgecollect then EVAL will compile the new code and load it on the stack.
Remarks
See Also
Example
Call EVAL(code)
If the code is a full Basic+ function which returns a value:
Declare function eval Ans = eval(code)
From TCL:
RUN EVAL 'CALL MSG(@window, "A Sample Message")'