There are three ways to define variables in a Net.Data macro:
A variable value received from form or query string data overrides a variable value set by a DEFINE statement in a Net.Data macro.
The simplest way to define a variable for use in a Net.Data macro is to use the DEFINE statement. The syntax is as follows:
%DEFINE variable_name="variable value" %DEFINE variable_name={ variable value on multiple lines of text %} %DEFINE { variable_name1="variable value 1" variable_name2="variable value 2" %}
The variable_name is the name you give the variable. Variable names must begin with a letter or underscore and can contain any alphanumeric character, an underscore, a period, or a hash (#). All variable names are case-sensitive, except N_columnName and V_columnName, which are table variables.
For example:
%DEFINE reply="hello"
The variable reply has the value hello.
Two consecutive quotes alone is equal to an empty string. For example:
%DEFINE empty=""
The variable empty has an empty string.
If your variable contains special characters, such as an end-of-line, use block braces around the value:
%DEFINE introduction={ Hello, My name is John. %}
To include quotes in a string, you can use two quotes consecutively.
%DEFINE HI="say ""hello"""
You can also use block braces to escape the quotes:
%DEFINE HI={ say "hello" %}
To define several variables with one DEFINE statement, use a DEFINE block:
%DEFINE { variable1="value1" variable2="value2" variable3="value3" variable4="value4" %}
You can use HTML FORM tags to assign values to variables, namely the SELECT, INPUT, and TEXTAREA tags. The following example uses standard HTML form tags to define Net.Data variables:
<INPUT NAME="variable_name" TYPE=...>
or
<SELECT NAME="variable_name"> <OPTION>value one <OPTION>value two </SELECT>
To assign a variable that spans multiple lines or contains special characters, such as quotes, the TEXTAREA tag can be used:
<TEXTAREA NAME="variable_name" ROWS="4"> Please type the multi-line value of your variable here. </TEXTAREA>
The variable_name is the name you give the variable, and the value of the variable is determined from the input received in the form. See HTML Forms for an example of how this type of variable definition is used in a Net.Data macro.
You can pass variables to Net.Data through the query string. For example:
http://www.ibm.com/cgi-bin/db2www/stdqry1.d2w/input?field=custno
In the above example, the variable name, field, and the variable value, custno, specify additional data that Net.Data receives from the query string. Net.Data receives and processes the data as it would from form data.