Purpose
The DEFINE section defines variables names in the declaration part of the macro and can be either a statement or a block.
The variable definition can be on a single line, using double quotes (""), or can span multiple lines, using brackets and a percent sign ({ %}). After the variable is defined, you can reference it anywhere in the macro.
Syntax
>>-%DEFINE----+----------------------------+--------------------> | (1) | '-(--+-STATIC---------+---)--' | (1) | '-TRANSIENT------' >-----+-| define entry |--------------------------+------------>< '-{--+------------------------------+---%}--' | .------------------------. | | V | | '----+-define entry------+--+--' '-include statement-' define entry .--------------------------. V | |---+-variable name--=--+-"-----+--------------------+--+---"---+-+-> | | +-string-------------+ | | | | +-variable reference-+ | | | | '-function call------' | | | | .--------------------------. | | | | V | | | | +-{-----+--------------------+--+---%}--+ | | | +-string-------------+ | | | | +-variable reference-+ | | | | +-function call------+ | | | | '-new_line-----------' | | | +-exec statement------------------------+ | | +-table statement-----------------------+ | | +-envvar statement----------------------+ | | +-| conditional variable |--------------+ | | '-| abbreviated conditional variable |--' | '-list statement----------------------------------------------' >---------------------------------------------------------------| conditional variable |---variable name---?-------------------------------------------> .--------------------------. V | >-----+-"-----+--------------------+--+---"---+-----------------> | +-string-------------+ | | +-variable reference-+ | | '-function call------' | | .--------------------------. | | V | | '-{-----+--------------------+--+---%}--' +-string-------------+ +-variable reference-+ '-function call------' .--------------------------. V | >-------:--+-"-----+--------------------+--+---"---+------------| | +-string-------------+ | | +-variable reference-+ | | '-function call------' | | .--------------------------. | | V | | '-{-----+--------------------+--+---%}--' +-string-------------+ +-variable reference-+ '-function call------' abbreviated conditional variable .--------------------------. V | |---?----+-"-----+--------------------+--+---"---+--------------| | +-string-------------+ | | +-variable reference-+ | | '-function call------' | | .--------------------------. | | V | | '-{-----+--------------------+--+---%}--' +-string-------------+ +-variable reference-+ '-function call------'
Notes:
Values
Context
The DEFINE block or statement must be in an IF block or outside all other blocks in the declaration part of the Net.Data macro.
Restrictions
%DEFINE var = "The value is $(var)."
Examples
Example 1: Simple variable definitions
%DEFINE var1 = "orders" %DEFINE var2 = "$(var1).html"
During run time, the variable reference $(var2) is evaluated as orders.html.
Example 2: Quotes inside a string
%DEFINE hi = "say ""hello""" %DEFINE empty = ""
When displayed, the variable hi has the value say "hello". The variable empty contains the empty string.
Example 3: Definition of multiple variables
%DEFINE{ DATABASE = "testdb" home = "http://www.ibm.com/software" SHOWSQL = "YES" PI = "3.14150" %}
Example 4: Multiple-line definition of a variable
%DEFINE text = {This variable definition spans two lines %}
Example 5: This example of a conditional variable demonstrates how the variable var takes the resulting value inside the quotations marks ("") if the resulting value does not contain any NULL values.
%DEFINE var = ? "Hello! $(V)@MyFunc()" %}