Skip to content

In Comparison Mode

Obsolete

The In comparison mode is replaced by the Contains operator.

See Also

Purpose

To specify "includes" as the operator for comparisons.

Syntax

{sub-string} in {host-string}

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

What It Does

Commands and loops can be controlled according to the results of comparisons of the values of two variables using the in operator.

Example 1

string sSub sAlphabet
move "abcdefgijklmnopqrstuvwxyz" to sAlphabet
move "abc" to sSub
if sSub in sAlphabet send Info_Box sSub "Part of Alphabet"

Example 2

string sCurrentName sLastName sPhoneNumber
move "Smith" to sLastName
direct_input channel 2 "PhoneBook.txt"
repeat
    read channel 2 sLastName sPhoneNumber
until sLastName in sCurrentName

Notes

  • The in operator can be used to determine whether literal numbers and the values of number and date variables are included in the contents of Numeric and Date variables.

  • The in operator is case sensitive.

  • For the if, indicate, until, and while commands, DataFlex uses eight comparison mode operators: eq, ge, gt, in, le, lt, ne, and match. The in and match operators operate according to the character contents of variables, while the other operators deal with sequences and numeric quantities.

  • The in operator is effective where the position of a search substring in the string being checked is unknown, variable, or irrelevant. If you wish to check only a known position in the string being checked, the "wildcard" characters of the match comparison mode are more useful.

  • In the contains operator, the target substring is given in the second argument, rather than in the first, as it is in the in comparison mode. Operators may be used in expressions, and may not be used outside them.