Net.Data Books

Administration and Programming Guide for OS/390

Referencing Variables

You can reference a previously defined variable to return its value. To reference a variable in Net.Data macros, specify the variable name inside $( and ). For example:

$(variableName)
$(homeURL)

When Net.Data finds a variable reference, it substitutes the variable reference with the value of the variable.

To use variables as part of your text presentation statements, reference them in the HTML blocks of your macro.

Valid variable names must begin with an alphanumeric character or an underscore, and they can consist of alphanumeric characters, including a period, underscore, and hash mark.

Example 1: Variable reference in a link

If you have defined the variable homeURL:

%DEFINE homeURL="http://www.ibm.com/"

You can refer to the home page as $(homeURL) and create a link:

<A href="$(homeURL)">Home page</A>

You can dynamically generate a variable name by including variable references, strings, and function calls within a variable reference. If you reference a dynamically-generated variable that does not follow the variable name rules, Net.Data resolves the reference to an empty string. See Net.Data Reference for more information on variable references.

Example: Dynamically generates a variable reference for a field value of a row

%WHILE (INDEX < NUM_COLS) {
 $(V$(INDEX))
 @DTW_ADD(INDEX, "1", INDEX)
 %}

You can reference variables in many parts of the Net.Data macro; check the language constructs in this chapter to determine in which parts of the macro variable references are allowed. If the variable has not yet been defined at the time it is referenced, Net.Data returns an empty string. A variable reference alone does not define the variable.


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