The local variables of the current process can be directly used in the code to run.
If the code is compiled without error, the code is run directly.
A fatal error is triggered if the code is not compiled.
If the source code used for the dynamic compilation contains names of files, items, controls, windows, reports, queries, ... these names must necessarily be enclosed in quotes.
For example, you must use: HReadFirst("Customer", "Name") instead of HReadFirst(Customer, Name)
The constants cannot be used
in the dynamic code (defined by the CONSTANT
When using constants in a code, all the occurrences of the constants are replaced by their value during the compilation in the editor but the correspondence between the name of constants and their value is not "embedded" in the application. Therefore, the dynamic compilation cannot use the constants.
Let's see two alternatives:
1 - Use variables instead of constants
2 - In the string containing the code that must be compiled dynamically, replace the name of the constant by its value:
sCode is string
// In the string containing the code that will be compiled dynamically
// instead of leaving the name of the constant:
// Replace the name of the constant by its value
sCode = Replace(sCode, "CST_Name", CST_Name, WholeWord + IgnoreCase)
// The code can be compiled now
IF Compile("DynProc", sCode) <> "" THEN
Error("Error while compiling the dynamic procedure: ", ...
// Then it can be run
WHEN EXCEPTION IN
Error("Error while running the dynamic procedure: ", ...