Xbasic

WORD Function

Syntax

Output_String as C = WORD(C character,N word_number[,C separator[,N num_words]])

Arguments

character

A character string.

word_number

An integer that specifies which word to return, counting left to right. If the Word_Number is negative, WORD() counts words from right to left. Numeric

separator

Optional. Default = space (" "). The character that delimits words. If the optional Word_Delimiter parameter is not specified, a word is any sequence of one or more characters separated either by a space or the start or end of the string. If Word_Delimiter is specified, then Alpha Anywhere returns the strings that are delimited by the Word_Delimiter character. If Word_Delimiter is null (e.g ""), then WORD() returns a null value. Contrast with WORD2() which treats a null word delimiter as being the same as the default delimiter (e.g. space " ").

num_words

Optional. Default = 1. Specifies the number of words in the Input_String to return.

Description

Returns a specified word(s) from a string.

Discussion

WORD() returns one or more words, specified by the Word_Number and Word_Count and delimited by Word_Delimiter, from the supplied Input_String.

Example

? word("This is a test", 4)
= "test"
dim FULLNAME as C = "Di King"
? word(FULLNAME, 1)
= "Di"
dim FULLNAME as C = "John J. Smith"
? word(FULLNAME, w_count(FULLNAME))
= "Smith"
? word("the quick brown fox", -1)
= "fox"
? word("John Smith, Alpha Software, BurlingtonMA01803", 3, ",")
= "BurlingtonMA01803"
? word("now is the time", 2, " ", 3)
= "is the time"

See Also