execute Considerations for COBOL
In the context of COBOL, the EGL execute statement is typically used to carry out a native COBOL statement with dynamic elements. Local EGL variables in the same program may be referenced in the statement, or labels within the same function. EGL will generate a COBOL statement containing the provided text, resolved variable and label names and embed this into the application program.
Syntax
execute
#cobol
{cobolStatement}
;
- cobolStatement
- For more information on the allowable contents of this type of statement, refer to the COBOL Language Reference manual. The contents of the cobolStatement can include any combination of text, variable references, or label references. Any text will be included as is, with no translation or case conversion. Any variable referenced must be a local EGL variable within the same EGL program. You may not reference a variable in another program or library. All variable references are preceded by a colon (:) to indicate that the following text is to be considered a variable that needs to be resolved. Any label referenced must be for an EGL label in the same function. You may not reference a label in another function. All label references are preceded by a percent sign (%) to indicate that the following text is to be considered a label that needs to be resolved.
Here is an example of the execute statement:
$MyName char(20) = "MYEGL";
$NameLength smallInt;
$LowerName char(20);
function main()
$tempVariable1 char(20);
execute #cobol{ MOVE FUNCTION LOWER-CASE( :$MyName) TO :$tempVariable1};
$LowerName = $tempVariable1;
Syslib.writeStdout("LOWER-CASE('" + $MyName + "') = " + $LowerName);
end