IBM Books

Reference


Word Functions

These functions supplement the string functions by modifying words or sets of words. Net.Data interprets a word as a space-delimited string, or a string with spaces on both sides. Here are some examples:

String value Number of words
one two three 3
one , two , three 5
Part 2: Internet Sales Grow 5

MBCS support for OS/390, OS/2, Windows NT, and UNIX: You can specify multiple-byte character set (MBCS) support for word and string functions with the DTW_MBMODE configuration value. Specify this value in the Net.Data initialization file; the default is no support. You can override the value in the initialization file by setting the DTW_MBMODE variable in a Net.Data macro. See the configuration variable section in Net.Data Administration and Programming Guide and DTW_MBMODE for more information.

MBCS support for OS/400: DBCS support is provided automatically and does not require this variable.

The following functions are word functions that Net.Data supports:

DTW_DELWORD


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Deletes words in a string, starting from word n for the number of words specified by length.

Format

@DTW_DELWORD(stringIn, n, length, stringOut)

@DTW_DELWORD(stringIn, n, stringOut)

@DTW_rDELWORD(stringIn, n, length)

@DTW_rDELWORD(stringIn, n)

Parameters

Table 105. DTW_DELWORD Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The word position of the first word to be deleted.
integer length IN The number of words to delete. The default is to delete all words from n to the end of stringIn. Optional parameter.
string stringOut OUT A variable that contains the modified form of stringIn.

Return Codes

Table 106. DTW_DELWORD Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1

@DTW_DELWORD("Now is the time", "5", result)

Example 2:

@DTW_DELWORD("Now is the time", "2", result)

Example 3:

@DTW_DELWORD("Now is the time", "2", "2", result)

Example 4:

@DTW_rDELWORD("Now is the time.", "3")

DTW_SUBWORD


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns a substring of a string, beginning at word n s for the number of words specified by length.

Format

@DTW_SUBWORD(stringIn, n, length, stringOut)

@DTW_SUBWORD(stringIn, n, stringOut)

@DTW_rSUBWORD(stringIn, n, length)

@DTW_rSUBWORD(stringIn, n)

Parameters

Table 107. DTW_SUBWORD Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The word position of the first word of the substring. A null is returned if this value is greater than the number of words in stringIn.
integer length IN The number of words in the substring. If this value is greater than the number of words from n to the end of stringIn, all words to the end of stringIn are returned. The default is to return all words from n to the end of stringIn.
string stringOut OUT A variable that contains a substring of stringIn specified by n and length.

Return Codes

Table 108. DTW_SUBWORD Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_SUBWORD("Now is the   time", "5", result)

Example 2:

@DTW_SUBWORD("Now is the   time", "2", result)

Example 3:

@DTW_SUBWORD(Now is the   time", "2", "2", result)

Example 4:

@DTW_rSUBWORD("Now is the   time", "3")

DTW_WORD


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the nthe word in a string.

Format

@DTW_WORD(stringIn, n, stringOut)

@DTW_rWORD(stringIn, n)

Parameters

Table 109. DTW_WORD Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The word position of the word to return. If this value is greater than the number of words in stringIn, a null is returned.
string stringOut OUT A variable that contains the word at word position n.

Return Codes

Table 110. DTW_WORD Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_WORD("Now is the time", "3", result)

Example 2:

@DTW_WORD("Now is the time", "5", result)

Example 3:

@DTW_rWORD("Now is the time", "4")

DTW_WORDINDEX


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the character position of the first character in the nth word of a string.

Format

@DTW_WORDINDEX(stringIn, n, stringOut)

@DTW_rWORDINDEX(stringIn, n)

Parameters

Table 111. DTW_WORDINDEX Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The word position of the word to index. If this value is greater than the number of words in the input string, 0 is returned.
string stringOut OUT A variable that contains the character position of the nth word of stringIn.

Return Codes

Table 112. DTW_WORDINDEX Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_WORDINDEX("Now is the time", "3", result)

Example 2:

@DTW_WORDINDEX("Now is the time", "6", result)

Example 3:

@DTW_rWORDINDEX("Now is the time", "2")

DTW_WORDLENGTH


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the length of the nth word of a string.

Format

@DTW_WORDLENGTH(stringIn, n, stringOut)

@DTW_rWORDLENGTH(stringIn, n)

Parameters

Table 113. DTW_WORDLENGTH Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
integer n IN The word position of the word whose length you want to know. If this value is greater than the number of words in the input string, 0 is returned.
string stringOut OUT A variable that contains the length of the nth word in stringIn.

Return Codes

Table 114. DTW_WORDLENGTH Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Examples

Example 1:

@DTW_WORDLENGTH("Now is the time", "1", result)

Example 2:

@DTW_rWORDLENGTH("Now is the time", "6")

DTW_WORDPOS


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the word number of the first occurrence of one string within another.

Format

@DTW_WORDPOS(stringIn1, stringIn2, n, stringOut)

@DTW_WORDPOS(stringIn1, stringIn2, stringOut)

@DTW_rWORDPOS(stringIn1, stringIn2, n)

@DTW_rWORDPOS(stringIn1, stringIn2)

Parameters

Table 115. DTW_WORDPOS Parameters

Data Type Parameter Use Description
string stringIn1 IN A variable or literal string.
string stringIn2 IN A variable or literal string to search.
integer n IN The word position in stringIn2 to begin searching. If this value is larger than the number of words in stringIn2, 0 is returned. The default is to search from the beginning of stringIn2.
string stringOut OUT The word position of stringIn1 in stringIn2.

Return Codes

Table 116. DTW_WORDPOS Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1001 An input parameter contained a NULL value.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.
1007 A parameter contains a value which is not valid.

Usage Notes

Multiple blanks are treated as single blanks for comparison.

Examples

Example 1:

@DTW_WORDPOS("the", "Now is the time", result)

Example 2:

@DTW_WORDPOS("The", "Now is the time", result)

Example 3:

@DTW_WORDPOS("The", "Now is the time", "5", result)

Example 4:

@DTW_WORDPOS("is  the", "Now is     the time", result)

Example 5:

@DTW_rWORDPOS("be", "To be or not to be", "3")

DTW_WORDS


AIX HP-UX Linux OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X X

Purpose

Returns the number of words in a string.

Format

@DTW_WORDS(stringIn, stringOut)

@DTW_rWORDS(stringIn)

Parameters

Table 117. DTW_WORDS Parameters

Data Type Parameter Use Description
string stringIn IN A variable or literal string.
string stringOut OUT A variable that contains the number of words in stringIn.

Return Codes

Table 118. DTW_WORDS Return Codes

Return Code Explanation
-1001 The server could not process a Net.Data request to allocate memory.
1003 The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function.
1005 A parameter passed on a function call, required to be a string variable, was of a different variable type.
1006 A literal string was passed on a function call for a parameter which was required to be an output parameter.

Examples

Example 1:

@DTW_WORDS("Now is the time", result)

Example 2:

@DTW_rWORDS(" ")


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