A program code is a set of code sections:
The procedures and functions can be called recursively: a procedure or a function can call itself - directly or via calling some other procedures or functions.
All code sections are reenterable: the same code section can be used by several program activations or Tasks at the same time.
Code sections must be declared before they can be used. Declarations include forward-declarations, external-declarations, and definitions.
A program code may contain not more than one forward-declaration of a code section, specified before its definition. Forward-definitions are used in programs containing two or more code sections calling each other, so it is not possible to define each section before it is used in the other code section.
External-declarations allow code sections to call code sections defined in separate program code modules. External-declarations are allowed only in the environments that support them, such as the Real-Time Application and Web Applications environments. See the environment description for more details. If the external-declaration specifies the code section name as a regular name, when this code section is used, the module with the same name as the code section name is loaded: if the external declaration is
function myName(param) external;
and the myName function is called, then the separate program code module "myName" is loaded, and its code section "myName" is called. The external-declaration may contain a qualified name, explicitly specifying the module name: if the external declaration is
function myModule::myName(param) external;
and the myModule::myName function is called, then the separate program code module "myModule" is loaded, and its code section "myName" is called. The code section name and its parameter names specified in an external-declaration must match the code section name and its parameter names specified in the code section definition given in an external program code module. The code section definition can specify more parameters than an external-declaration. The missing parameters are assigned null-values when such an external-declaration is used.
A program code should contain exactly one external-declaration or exactly one definition (but not both) of each code section used.
An entry declaration consists of the entry keyword, the entry name, followed by one of the following:
for a forward-declaration:
for an entry definition:
for an alternative entry definition:
If a running program reaches the end of an entry section operator sequence, an implicit stop operator is executed.