In Comparison Mode
Obsolete
The In comparison mode is replaced by the Contains operator.
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
inoperator 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
inoperator is case sensitive. -
For the
if,indicate,until, andwhilecommands, DataFlex uses eight comparison mode operators:eq,ge,gt,in,le,lt,ne, andmatch. Theinandmatchoperators operate according to the character contents of variables, while the other operators deal with sequences and numeric quantities. -
The
inoperator 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 thematchcomparison mode are more useful. -
In the
containsoperator, the target substring is given in the second argument, rather than in the first, as it is in theincomparison mode. Operators may be used in expressions, and may not be used outside them.