Stand-alone function part
Stand-alone function parts support migration from languages that do not use libraries.
Any function that is not contained within another part is a stand-alone
function part. Stand-alone function parts have the following characteristics:
- Unlike regular functions, stand-alone functions are parts and cannot be included within another part.
- Set the includeReferencedFunctions program property to YES in any program that calls a stand-alone function. For details, see includeReferencedFunctions.
- Stand-alone functions should not be used in new code.
- When you use stand-alone functions, you might need to use the containerContextDependent property to resolve references. For details, see containerContextDependent.
Example
The following example shows a stand-alone function.
package com.CompanyB.CustomerPackage;
// stand-alone function--outside program
function printBalance (pBal DECIMAL(7,2) in)
writeStdOut (strLib.formatNumber(pBal));
end
program BalanceCheck type BasicProgram {
includeReferencedFunctions = YES // without this property
} // cannot find printBalance()
customer INT = 1;
balance DECIMAL(7,2) = 0;
function main()
while (balance >= 0)
balance = getCustomerBalance(customer); // returns -1
printBalance (balance);
end // while
end // main
function getCustomerBalance (custNo INT in) returns (DECIMAL(7,2))
...
end // function
end // program
Compatibility
| Platform | Issue |
|---|---|
| VisualAge® Generator compatibility mode | The containerContextDependent property provides functionality that was available in VisualAge® Generator with regard to resolving references from stand-alone functions; all references to functions and parts are resolved as if the function were embedded within the logic part that invokes it. See containerContextDependent. |