resulttype funcname ( parameterlist ) := EMBED( language, code );
|resulttype||The ECL return value type of the function.|
The ECL definition name of the function.
|parameterlist||A comma separated list of the parameters to pass to the function.|
|code||The source code to embed.|
The parameter types that can be passed and returned will vary by language, but in general the simple scalar types (INTEGER, REAL, STRING, UNICODE, BOOLEAN, and DATA) and SETs of those scalar types are supported, so long as there is an appropriate data type in the language to map them to.
The first form of EMBED is the structure that must terminate with ENDEMBED. This may contain any code in the supported language.
The second form of EMBED is a self-contained function. The code parameter contains all the code to execute, making this useful only for very simple expressions.
You can use EMBED instead of BEGINC++ to embed C++ code and specify additional options (for example, DISTRIBUTED) using this form:
myFunction(string name) := EMBED(C++ [: options]) ... text ENDEMBED
WARNING: This feature could create memory corruption and/or security issues, so great care and forethought are advised--consult with Technical Support before using.
//First form: a structure IMPORT Python; //make Python language available INTEGER addone(INTEGER p) := EMBED(Python) # Python code that returns one more than the value passed to it if p < 10: return p+1 else: return 0 ENDEMBED; //Second form: a function INTEGER addtwo(INTEGER p) := EMBED(Python, 'p+2');