WHILE Block

Purpose

Provides a looping construct based on conditional string processing. You can use the WHILE block in the HTML block, the REPORT block, the ROW block, the IF block, and the MACRO_FUNCTION block. String values in the condition list are treated as numeric for comparisons if they are strings that represent integers and have no leading or trailing white space. They can have a single leading plus (+) or minus (-) sign.

Syntax

>>-%WHILE--| condition list |---{------------------------------->
 
      .--------------------------.
      V                          |
>--------+--------------------+--+--%}-------------------------><
         +-function call------+
         +-HTML statement-----+
         +-if block-----------+
         +-include statement--+
         +-while block--------+
         +-variable reference-+
         '-string-------------'
 
condition list
 
|---(--+-(--condition list--)----------------+---)--------------|
       +-condition list--&&--condition list--+
       +-condition list--||--condition list--+
       +-!--condition list-------------------+
       +-| condition |-----------------------+
       '-| term |----------------------------'
 
condition
 
|---term--+-<--+---term-----------------------------------------|
          +->--+
          +-<=-+
          +->=-+
          +-!=-+
          '-==-'
 
term
 
|---+-variable_name-----------------------+---------------------|
    +-variable reference------------------+
    +-function call-----------------------+
    |    .-------------------------.      |
    |    V                         |      |
    '-"----+-string-------------+--+---"--'
           +-variable reference-+
           '-function call------'
 

Values

%WHILE
The keyword that specifies loop processing.

condition list
Compares the values of 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. An IF condition is treated as a numeric comparison if both of the following conditions are true:

If either condition is not true, a normal string comparison is performed.

term
A variable name, string, variable reference, for function call.

function call
Invokes one or more FUNCTION or MACRO_FUNCTION blocks, or built-in functions with specified arguments. See Function Call (@) for syntax and examples.

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

if block
The IF block. Performs conditional string processing. String values in the condition list are treated as numeric for comparisons if they represent integers and have no leading or trailing white space. They can have one leading plus (+) or minus (-) sign. See IF Block 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.

while block
The WHILE block. Performs looping with conditional string processing. See WHILE Block for syntax and examples.

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

string
Any sequence of alphabetic and numeric characters and punctuation. A string in the term of the condition list can contain any character except the new-line character.

variable name
A name that identifies a variable. See Variable Name for syntax information.

Context

The WHILE block can be found in these contexts:

Restrictions

The WHILE block can contain these elements:

Examples

Example 1: A WHILE block that generates rows in a table

%DEFINE loopCounter = "1"
 
%HTML(build_table) {
%WHILE (loopCounter <= "100") {
  %{ generate table tag and column headings %}
  %IF (loopCounter == "1")
     <table border>
     <tr>
     <th>Item #
     <th>Description
     </tr>
  %ENDIF
 
  %{ generate individual rows %}
  <tr>
  <td>
  <td>$(loopCounter)
  <td>@getDescription(loopCounter)
  </tr>
 
  %{ generate end table tag %}
  %IF (loopCounter == "100")
     </table>
  %ENDIF
 
  %{ increment loop counter %}
  @dtw_add(loopCounter, "1", loopCounter)
%}
%}
 
 
 


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