Functions

Functions allow you to perform a programming task multiple times with different values. A function is declared in the functions section of a script, in a library, or in a separate function script (include).

The possibilities for calling a function depend on how the function is declared:

  • If a function is declared in the declaration section of a script, you can only call the function within that script.
  • If a function is declared in a library, or in a separate function script, you can call the function in multiple scripts and libraries.

For more information, refer to "Functions" in the "3GL Language Features" section in the Infor ES - podręcznik programisty.

Przykład

The supplier session calculates the cumulative order volume within the last 30, 60 and 90 days. You declare a function that can perform this calculation for any range of days. The function has a type so that it can be used in an expression.

function domain cxquan supplier_volume(long day1,long day2)
{
    ... commands here ...
return( ... ) 
}

If the function is declared as a type, it must provide a return value. You call this function using the syntax:

vol_30 = supplier_volume(0,30)
vol_60 = supplier_volume(30,60)
To create functions

To create a function in a program script or in a library, you must edit the script/library via the Program Scripts / Libraries (ttadv2530m000) session. If you define a function in a library, you must link that library to the scripts and libraries where you want to call the function.

To create a function in a separate function script:(include), you must create the function script through the Functions (ttadv2560m000) session. You must include this function script (through an "#include" statement) in the scripts and libraries where you want to call the function.