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:

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

Table 1. Compatibility considerations for stand-alone functions
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.”

Feedback