Contains Operator

See Also: Constrain Command, Pos Function, Uppercase Function, Lowercase function

Purpose

Returns true from an expression in which the value of the second string is contained within the value of the first string.

Syntax

( {host-string} contains {sub-string} )

where {host-string} is the string being parsed; and {sub-string} the string being searched for. {host-string} and {sub-string} can be either a literal or a string variable.

What It Does

When the value of {sub-string} is present in the value of {host-string}, a contains expression evaluates to 1 (true), and when it is not, it evaluates to 0 (false).

Example

string sTitle

 

if ((sTitle contains "engineer") OR (sTitle contains "manager")) ;

    send DoCalcBonus

In this example, the procedure DoCalcBonus is called for any value of the string variable title that contains either "engineer" or "manager".

Example

string sFruit

 

if (uppercase(sFruit) contains "APPLE") ;

    send DoMakeCider

In this example, the procedure DoMakeCider is called whenever the value of the string variable sFruit is made up of the letters of "APPLE", regardless of their capitalization.

Notes