Xbasic

$ (Substring Inclusion Operator)

Syntax

Result as L = Find_String as C $ Search_String as C

Arguments

Find_StringCharacter

The character string that you are looking for.

Search_StringCharacter

The character string to examine.

Returns

ResultLogical

Returns .t. if Search_String is found in Find_String, otherwise .f.

Description

The $ operator determines whether the character expression on the left of the operator is contained anywhere within the character expression on the right.

Discussion

Operations involving the $ operator return a logical result (i.e., TRUE or FALSE). The string comparison is not case sensitive. If Find_String is a null string ("") then this operator will return TRUE. While this seems a meaningless comparison, this can happen if your Find_String is stored in a variable and you neglect to test whether the variable string is empty before using this operator in an expression or script. See also Character Search Functions.

Example:

For example, if Company contains "The Computer Store":

dim Company as C
Company = "The Computer Store"

? "Computer" $ Company
= .T.

? "computer" $ Company
= .T.

? "computer" $ LOWER(Company)
= .T.


? "" $ "alpha"
= .T.

? " " $ "alpha"
= .F.

See Also