독립형 함수 함수

독립형 함수 파트는 라이브러리를 사용하지 않는 언어에서 마이그레이션하도록 지원합니다.

다른 파트에 포함되지 않은 함수는 독립형 함수 파트입니다. 독립형 함수 파트에는 다음 특성이 있습니다.
  • 일반 함수와 달리 독립형 함수는 파트이며 다른 파트에 포함될 수 없습니다.
  • 독립형 함수를 호출하는 프로그램에서 includeReferencedFunctions 프로그램 특성을 YES로 설정하십시오. 세부사항은 “includeReferencedFunctions”를 참조하십시오.
  • 새 코드에서는 독립형 함수를 사용하지 마십시오.
  • 독립형 함수를 사용하는 경우 참조를 해석하기 위해 containerContextDependent 특성을 사용해야 할 수 있습니다. 세부사항은 “containerContextDependent”를 참조하십시오.

예제

다음 예제는 독립형 함수를 표시합니다.
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

호환성

표 1. 독립형 함수의 호환성 고려사항
플랫폼 문제
VisualAge® Generator 호환 모드 containerContextDependent 특성은 독립형 함수의 참조 해석과 관련하여 VisualAge Generator에서 사용 가능한 기능을 제공합니다. 함수와 파트에 대한 모든 참조는 함수가 이를 호출한 논리 파트에 임베디드되었던 것처럼 해석됩니다. “containerContextDependent”를 참조하십시오.