IBM Books

Net.Data 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 file. 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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns a substring of the input string. Words are deleted 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)

Values

Table 61. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns a substring of the input string. The substring begins at word n and continues 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)

Values

Table 62. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns a single word from a specified position of the input string.

Format

@DTW_WORD(stringIn, n, stringOut)

@DTW_rWORD(stringIn, n)

Values

Table 63. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

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

Format

@DTW_WORDINDEX(stringIn, n, stringOut)

@DTW_rWORDINDEX(stringIn, n)

Values

Table 64. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns the length of the nth word of the input string.

Format

@DTW_WORDLENGTH(stringIn, n, stringOut)

@DTW_rWORDLENGTH(stringIn, n)

Values

Table 65. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
X X X X X X X X

Purpose

Returns the word number of the first occurrence of one string within another. Multiple blanks are treated as single blanks for comparison. The comparison is case sensitive.

Format

@DTW_WORDPOS(stringIn1, stringIn2, n, stringOut)

@DTW_WORDPOS(stringIn1, stringIn2, stringOut)

@DTW_rWORDPOS(stringIn1, stringIn2, n)

@DTW_rWORDPOS(stringIn1, stringIn2)

Values

Table 66. 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.

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 OS/2 OS/390 OS/400 SCO SUN Win NT
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)

Values

Table 67. 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.

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 ]