IBM Books

Net.Data Reference Guide


Word Functions

These functions supplement the string functions and modify 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

DTW_DELWORD

Purpose


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

Returns a substring of the input string. Words are deleted from word n for the number of words specified by length.

Syntax

Parameters

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

Purpose


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

Returns a substring of the input string. The substring begins at word n and continues for the number of words specified by length.

Syntax

Parameters

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

Purpose


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

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

Syntax

Parameters

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

Purpose


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

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

Syntax

Parameters

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

Purpose


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

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

Syntax

Parameters

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

Purpose


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

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

Syntax

Parameters

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

Purpose


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

Returns the number of words in a string.

Syntax

Parameters

Table 39. 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 ]