IBM Books

Net.Data Reference Guide

DEFINE Block or Statement

Purpose

The DEFINE block or statement defines variables names. Variable names must begin with a letter or underscore (_) and contain any alphanumeric characters or underscore. All variable names are case sensitive except N_columnName and V_columnName (See "Implicit Table Variables" for more information about these two exceptions.).

Syntax

>>-%define---+-| 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 |----------+|
   +-list statement-----------------------------------------+
 
conditional variable
 
                           +-----------------------+
                           V                       |
|--variable name--?---+-"----+--------------------++--"---+----->
                      |      +-string-------------+       |
                      |      +-variable reference-+       |
                      |      +-function call------+       |
                      |    +-----------------------+      |
                      |    V                       |      |
                      +-{----+--------------------++--%}--+
                             +-string-------------+
                             +-variable reference-+
                             +-function call------+
 
>--+-----------------------------------------+-----------------|
   |         +-----------------------+       |
   |         V                       |       |
   +-:--+-"----+--------------------++--"---++
        |      +-string-------------+       |
        |      +-variable reference-+       |
        |      +-function call------+       |
        |    +-----------------------+      |
        |    V                       |      |
        +-{----+--------------------++--%}--+
               +-string-------------+
               +-variable reference-+
               +-function call------+
 

Parameters

%define

A keyword that defines variables.

define entry:

variable name

One or more names, each additional name concatenated by a period (.). See Variable Name for syntax information.

string

Any sequence of alphabetic and numeric characters and punctuation except a tabulator, new line character, or a space.

variable reference

Returns the value of a previously defined variable and is specified with $ and (). For example: if VAR = 'abc', then $(VAR) returns the value 'abc'. See Variable Reference for syntax information.

function call

Invokes one or more previously defined FUNCTION blocks with specified arguments. See Function call (@) for syntax and examples.

exec statement

The EXEC statement. The name of an external program that executes when a variable is referenced or a function is called. See EXEC Block or Statement for syntax and examples.

table statement

The TABLE statement. Defines a collection of related data containing an array of identical records, or rows, and an array of column names describing the fields in each row. See TABLE Statement for syntax and examples.

envvar statement

The ENVVAR statement. Refers to environment variables. See ENVVAR Statement for syntax and examples.

conditional variable

Sets the value of a variable based on the value of another variable or string.

list statement

The LIST statement. Defines variables that are used to build a delimited list of values. See LIST Statement for syntax and examples.

include statement

The INCLUDE statement. Reads and incorporates a file into the Net.Data macro. See INCLUDE Statement for syntax and examples.

Context

Must be in a macro IF block or outside all other blocks in the declaration part of the Net.Data macro.

Restrictions

Can contain the following elements:

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: Include quotes in a string by using two consecutive quotes. Two quotes alone is a null string.

%DEFINE hi = "say ""hello"""
%DEFINE empty = ""
When displayed, the variable hi has the valuesay "hello". The variable empty is null.

Example 3: A DEFINE block lets you define multiple variables with one DEFINE statement.

%DEFINE{  DATABASE = "testdb"
          home = "http://www.software.ibm.com"
          SHOWSQL = "YES"
          PI = "3.14150"
%}

Example 4: This example of a definition block lets you define one variable spanning multiple lines.

%DEFINE text = {This variable definition
            spans two lines
%}


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]