EXPORT functions and procedures

With export functions you can write functions and procedures in Code Libraries available to all Master Templates in the project you are working on.

Export functions are specified using the EXPORT keyword prefix. Export functions can only be defined in Code Libraries, and they cannot be defined in conditional statements or other nested constructs. An exported function can be used in Master Templates and in higher-numbered Code Libraries.

To use Microsoft Word instructions in Code Libraries, you must assign content containing Microsoft Word instructions to Data Backbone Fields in a Master Template. Use these fields in Code Libraries when manipulating layout. Microsoft Word instructions typed directly in Code Libraries are stripped. Microsoft Word instructions are also stripped for the AiaDocXML output and HTML output.

EXPORT FUNC returntype function (parameters)
DO
  ...
OD

EXPORT PROC procedure (parameters)
DO
  ...
OD

Any function or procedure can be exported.

FUNC BOOL is_div (CONST NUMBER a; CONST NUMBER b)
DO
  ASSIGN is_div := ((a/b) = truncate (a/b; 0))
OD

EXPORT
FUNC BOOL is_leap_year (CONST NUMBER year)
DO
  ASSIGN is_leap_year := (is_div (year; 4) AND NOT is_div (year; 100)) OR is_div (year; 400)
OD

The preceding code tests if a year is a leap years. The main function is_leap_year is available in other Code Libraries and Master Templates. The helper function is_div is not exported and can only be used in the Code Library it is defined in.