Match Comparison Mode
Obsolete
This comparison mode is not supported in DataFlex versions 7.0 and beyond. Use the contains operator or pos function.
Indicators are also obsolete, with the exception of predefined indicators that already exist in the language. Among the reasons for this is the limit of 89 user-defined indicators per program and that indicators are global.
Use the Boolean command to declare Boolean variables instead or declare properties in classes and objects. You can use the move command to set and retrieve the value of indicators.
Purpose
To specify "matching" as the operator for comparisons.
Syntax
Commands and loops can be controlled according to the results of comparisons of the values of two variables using the match operator:
indicate
indicator
as
variable
match
variable
See Indicate Command for a description of that command.
if
variable
match
variable
command
See If Command for a description of that command.
repeat
command
:
command
until
variable
match
variable
See Repeat Command for a description of that command.
while
variable
match
variable
command
:
command
end
See While Command for a description of that command.
Match allows the use of the question mark (?) and asterisk (*) "wildcard" characters so that varying strings having specified characters in common may match. As in many operating system directories, the question mark may be placed in the "standard" string in any position where any single character is acceptable, and the asterisk may be placed where any series of characters of any length is acceptable.
Thus, the following comparisons are true:
if "Mac?ntosh" match "MacIntosh" . . .
if "Mac?nt*" match "MacIntosh" . . .
if "????ntosh" match "MacIntosh" . . .
if "*Intosh" match "MacIntosh" . . .
The "standards" (Mac?ntosh, Mac?nt, and Intosh) would accept successively larger subsets of data from a database. *Intosh, in fact, would accept everything in a database (would never be false), because the initial asterisk would accept all entries and the "Intosh" after it would have no effect. Asterisks, then, are useful only as a way of accepting trailing substrings, as used in the second example above.
Wildcards may be used only in the first variable. When used in the second variable, asterisks and question marks are treated as literal characters. Thus, the following test is true:
if "ABC*" match "ABCD" . . .
while the following test is false:
if "ABCD" match "ABC*" . . .
When seeking a match for strings containing literal question marks and asterisks, you should place the "standard" string in the second variable, where they are treated as literal characters. By the same token, where a loop is "cycling" database values which might contain asterisks and question marks into a match test, those values must be "cycled" into the match in the second position in order to make a coincidental wildcard match impossible.
Notes
-
Match with wildcards can be used to determine whether literal numbers and the values of number and date variables are within the contents of numeric and date variables. Thus, the following sequences result in true comparisons:
move (3 / 2) to a_number if "1.5" match a_number . . . if "?.*" match a_number . . . move 12/24/44 to a_date if "12/24/*" match a_date . . . move "12/24/*" to a_string if a_string match a_date . . . -
Match is case sensitive. Thus, the following comparison would be false:
if "abc" match "ABC" . . . -
For the if, indicate, until, and while commands, DataFlex uses eight Comparison Mode operators:
eq,ge,gt,in,le,lt,ne, andmatch. In and match operate according to the character contents of variables, while the other operators deal in numeric quantities and sequences. -
The
eqcomparison/find mode can be used to detect exact matches of strings, but it does not accommodate the * and ? "wildcard" characters. -
The "wildcard" characters in match are useful for detecting the presence of substrings in a known position in the string being checked. The
incomparison mode is more effective where the position of a search substring is unknown, variable, or irrelevant. -
In the matches Operator, the wildcard characters are effective in the second-given argument, rather than in the first, as they are in the match comparison mode. Operators are used in expressions, and may not be used outside them.