Standalone Function part

Standalone Function parts support migration from languages that do not use libraries.
Any function that is not contained within another part is a Standalone Function part. Standalone Function parts have the following characteristics:

Example

The following example shows a standalone function.
package com.CompanyB.CustomerPackage;

// standalone 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 standalone functions
Platform Issue
VisualAge® Generator compatibility mode The containerContextDependent property provides functionality that was available in VisualAge Generator with regard to resolving references from standalone functions; all references to functions and parts are resolved as if the function were embedded within the logic part that invokes it. See containerContextDependent.
Text UI When you read a form field into a function as a parameter, it can carry the additional modifier field, telling the function that the parameter can be tested for attributes such as blanks and numeric. In this case, the parameter must carry the inOut modifier. The field modifier is not available for function arguments in a service or in a NativeLibrary.

Feedback