IBM Books

Net.Data Reference Guide

Macro IF Block

Purpose

The macro IF block performs conditional string processing and is used within the declaration part of the Net.Data macro. Numeric values are treated as strings for comparisons.

Syntax

                             +-----------------------+
                             V                       |
>>-%if--| condition list |-----+--------------------++---------->
                               +-exec_sql statement-+
                               +-define statement---+
                               +-function statement-+
                               +-function call------+
                               +-HTML block---------+
                               +-message block------+
 
>--| else_if spec |--%endif------------------------------------><
 
condition list
 
|--(--+-(--condition list--)----------------+-)----------------|
      +-condition list--&&--condition list--+
      +-condition list--||--condition list--+
      +-!--condition list-------------------+
      +-| condition |-----------------------+
      +-| term |----------------------------+
 
condition
 
|--term--+-<--+-term-------------------------------------------|
         +->--+
         +-<=-+
         +->=-+
         +-!=-+
         +-==-+
 
term
 
|--+-variable reference-+--------------------------------------|
   +-"--string--"-------+
   +-variable name------+
 
else_if spec
 
|--+----------------------------------------------------------------+->
   |    +-------------------------------------------------------+   |
   |    |                             +-----------------------+ |   |
   |    V                             V                       | |   |
   +--+--%elif--(--condition_list--)----+--------------------++-+-+-+
      |                                 +-exec_sql statement-+    |
      |                                 +-define statement---+    |
      |                                 +-function statement-+    |
      |                                 +-function call------+    |
      |                                 +-HTML block---------+    |
      |                                 +-message block------+    |
      |        +-----------------------+                          |
      |        V                       |                          |
      +-%else----+--------------------++--------------------------+
                 +-exec_sql statement-+
                 +-define statement---+
                 +-function statement-+
                 +-function call------+
                 +-HTML block---------+
                 +-message block------+
 
>--------------------------------------------------------------|
 

Parameters

%if

The keyword that specifies conditional string processing. Numeric values are treated as strings for comparisons.

condition list:

condition list

Compares values and variable values. The list can contain conditions and terms. Condition lists can be connected using boolean operators. A condition list can be nested inside another condition list.

condition

A comparison between two terms using comparison operators. Net.Data compares only strings; a variable or a string representing a numerical value is evaluated as a string of characters, not as a numerical value.

term

A variable name, string, or variable reference.

exec_sql statement

A DB2WWW Release 1 language element supported for compatibility. See Appendix A. "DB2 WWW Connection" or DB2 World Wide Web Release 1 documentation.

define statement

The DEFINE block or statement. Defines variables and sets configuration variables. Variable names must begin with a letter or underscore (_) and contain any alphanumeric characters or underscore. See DEFINE Block or Statement for syntax and examples.

function block

A keyword that specifies a subroutine that can be invoked from the Net.Data macro. The executable statements in a function block can contain language statements directly interpreted by a language environment, or they can indicated a call to an external program. See FUNCTION block for syntax and examples.

function call

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

HTML block

Includes any alphabetic or numeric characters, and HTML tags to be formatted for the client's browser.

message block

The MESSAGE block. A set of return codes, the associated messages, and the actions Net.Data takes when a function call is returned. See MESSAGE Block for syntax and examples.

%elif

A keyword that starts the alternative processing path, and can contain condition lists and most Net.Data macros.

%endif

A keyword that closes the IF block.

%else

A keyword that executes associated statements if all other condition lists are not satisfied.

Context

Can be found in these contexts:

Restrictions

Can contain these elements:

Examples

Example 1:

%IF ($(DTW_HTML_TABLE))
%define OUT_FORMAT = "HTML"
%ELSE
%define OUT_FORMAT = "CHARACTER"
%endif


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