These are general-purpose functions that you can use:
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Replaces single quotes in an input string with two single quotes. This is needed for SQL statements to complete successfully if a string contains a single quote.
Syntax
Parameters
Table 1. DTW_ADDQUOTE Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | stringIn | IN | A variable or literal string. DTW_mADDQUOTE can have multiple input strings. |
| string | stringOut | OUT | A variable that contains the modified form of stringIn. |
| string | stringMult | INOUT |
|
Examples
Example 1:
@DTW_ADDQUOTE(string1,string2)
Example 2:
@DTW_rADDQUOTE("The article's title is 'Once upon a time'")
Example 3:
@DTW_mADDQUOTE(string1,string2)
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Returns the current system date in the specified format.
Syntax
Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | format | IN | A variable or literal string specifying the data format. Valid formats
include:
The default is N. |
| string | stringOut | OUT | A variable that contains the date in the specified format. |
Examples
Example 1:
@DTW_DATE(results)
Example 2:
@DTW_DATE("E", results)
Example 3:
%HTML(report){
<P>This report created on @DTW_rDATE("U").
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Returns the value of the specified environment variable. You can also use ENVVAR to get the values of environment variables. For more information, see ENVVAR Statement.
Syntax
Parameters
Table 3. DTW_GETENV Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | envVarName | IN | A variable or literal string. |
| string | envVarValue | OUT | The value of the environment variable specified in envVarName. A null string is returned if the value is not found. |
Examples
Example 1:
@DTW_GETENV(myEnvVarName, myEnvVarValue)
Example 2:
@DTW_rGETENV(myPath)
Example 3:
The server is @DTW_rGETENV("SERVER_NAME").
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Returns the value of the specified configuration variable. If a value is not found, a null string is returned.
| Note: | Special configuration path variables, MACRO_PATH, EXEC_PATH, and INCLUDE_PATH, as well as ENVIRONMENT statements cannot be retrieved with this call. |
Syntax
Parameters
Table 4. DTW_GETINIDATA Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | iniVarName | IN | A variable or literal string. |
| string | iniVarValue | OUT | The value of the configuration variable specified in iniVarName. |
Examples
Example 1:
@DTW_GETINIDATA(myEnvVarName, myEnvVarValue)
Example 2:
@DTW_rGETINIDATA("HTTP_COOKIE")
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Encodes characters using standard HTML decimal escape codes for many, but not all, characters. You can use this function to encode data that you do not want the browser to interpret as HTML. For example, by using the appropriate escape character , you can display less than (<) and greater than (>) signs, which are usually reserved for HTML tags.
In a second example, the string
"1 2 3"
in HTML only shows one space between each number. Use DTW_HTMLENCODE to ensure the right number of spaces are shown.
The follwoing characters are encoded by the DTW_HTMLENCODE function:
Table 5. HTML decimal escape characters
| Character | Name | Code |
| SPACE | Space |   |
| " | Double quote | " |
| # | Number sign | # |
| % | Percent | % |
| & | Ampersand | & |
| / | Backslash | \ |
| : | Colon | : |
| ; | Semicolon | ; |
| < | Less than | < |
| = | Equals | =: |
| > | Greater than | >: |
| ? | Question mark | ?: |
| @ | At sign | @ |
| [ | Left bracket | ( |
| \ | Slash | / |
| ] | Right bracket | ) |
| ^ | Carat | ^ |
| { | Left brace | { |
| | | Straight line | | |
| } | Right brace | } |
| ~ | Tilde | ~ |
Syntax
Parameters
Table 6. DTW_HTMLENCODE Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | stringIn | IN | A variable or literal string. |
| string | stringOut | OUT | A variable containing the modified input string where certain characters have been replaced by the HTML escape character encoding. |
Examples
Example 1:
@DTW_HTMLENCODE(string1,string2)
Example 2:
@DTW_rHTMLENCODE("X <= 10")
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Performs the same function as @DTW_HTMLENCODE, but also encodes the single quote characet (') to . The HTML decimal escape characters that DTW_QHTMLENCODE uses are shown in Table 5.
Consider using this function for all SQL INPUT statements. For example, if you enter O'Brien as a last name, as in the following example, the single quote might give you an error:
INSERT INTO USER1.CUSTABLE (LNAME, FNAME)
VALUES ('O'Brien', 'Patrick')
Using the DTW_QHTMLENCODE function changes the SQL statement prevents
the error:
INSERT INTO USER1.CUSTABLE (LNAME, FNAME)
VALUES ('O'Brien', 'Patrick')
See Example 3 for details.
Syntax
Parameters
Table 7. DTW_QHTMLENCODE Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | stringIn | IN | A variable or literal string. |
| string | stringOut | OUT | A variable that contains the modified form of stringIn where certain characters are replaced by the HTML escape character encoding. |
Examples
Example 1:
@DTW_QHTMLENCODE(string1,string2)
Example 2:
@DTW_rQHTMLENCODE("John's & Jane's")
Example 3:
%FUNCTION(DTW_SQL) insertName(){
INSERT INTO USER2A.SURVEY
(NAME) VALUES '@DTW_rQHTMLENCODE(fullname)'
%}
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Sets an environment variable with a specified value and returns the previous value. A null string is returned if no previous value is found.
Syntax
Parameters
Table 8. DTW_SETENV Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | envVarName | IN | A variable or literal string representing the environment variable. |
| string | envVarValue | OUT | A variable or literal string with the value to which the environment variable is set. |
| string | prevValue | OUT | A variable that contains the previous value of the environment variable. DTW_rSETENV returns the value as the function return value. |
Examples
Example 1:
@DTW_SETENV("PATH", "myPath", prevValue)
Example 2:
@DTW_rSETENV("PATH", "myPath")
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Returns the current system time in the specified format.
Syntax
Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | stringIn | IN | A variable or literal string specifying the time format. Valid formats
are:
|
| string | stringOut | OUT | A variable that contains the time in the specified format. |
Examples
Example 1:
@DTW_TIME(results)
Example 2:
@DTW_TIME("C", results)
Example 3:
@DTW_rTIME("M")
Example 4:
%REPORT{
<P>This report was created at @DTW_rTIME(), @DTW_rDATE().
%}
Purpose
| AIX | HP-UX | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
| X | X | X | X | X | X | X | X |
Replaces characters not allowed in a URL with their escaped values. You
must use this function to pass any of the characters listed in Table 10 to another macro file or HTML block.
Table 10. Characters disallowed in URLs
| Character | Name | Code |
| SPACE | Space |  |
| " | Double quote |  |
| # | Number sign |  |
| % | Percent |  |
| & | Ampersand |  |
| / | Backslash | F |
| : | Colon | A |
| ; | Semicolon | B |
| < | Less than | C |
| = | Equals | D |
| > | Greater than | E |
| ? | Question mark | F |
| @ | At sign | ( |
| [ | Left bracket | B |
| \ | Slash | C |
| ] | Right bracket | D |
| ^ | Carat | E |
| { | Left brace | B |
| | | Straight line | C |
| } | Right brace | D |
| ~ | Tilde | E |
Syntax
Parameters
Table 11. DTW_URLESCSEQ Parameters
| Data Type | Parameter | Use | Description |
|---|---|---|---|
| string | stringIn | IN | A variable or literal string. |
| string | stringOut | OUT | A variable containing the input string with characters not allowed in URLs replaced with their hexidecimal escape values. |
Examples
Example 1:
@DTW_URLESCSEQ(string1,string2)
Example 2:
@DTW_rURLESCSEQ("Guys & Dolls")
Example 3: This example uses DTW_rURLESCSEQ in a ROW block. When the application user clicks on the name, the name and e-mail address are sent to the input block of the Net.Data macro fullrpt.mac with the encoded values as variables name and email.
%ROW{
<P><a href="fullRpt.mac/input?name=@DTW_rURLESCSEQ(V1)&email=@DTW_rULRESCSEQ(V2)">
$(V1)</a>
%}
<P><a href="fullrpt.mac/input?name=Patrick%20O'Brien&email="obrien%40ibm.com"> Patrick O'Brien</a>