xcall MATCH, rtncod, value, range
MATCH.SBR is useful in building flexible record selection logic. With it, you can easily allow the users to specify a list of acceptable values, or ranges of values, for a particular field. Then for each candidate record, just pass the value and range specification to the subroutine and let it worry about numeric, string, and date comparisons.
Parameters
rtncod (Signed Num)
returns the results:
Value |
Meaning |
0 |
No match; value is not within the specified list or range |
1 |
Match; value is within range |
-1 |
Parameter error |
-2 |
Value type not supported |
-3 |
Range string too long |
-4 |
Syntax error in range |
value (F,6, (String), or B#)
is the value which you want to check against the range.
range
is the range specification in the form:
r1,r2,r3,...,rn
Each of the rx entries in the range string may be either a single value or a from-to range expressed as a beginning and ending value, separated by a dash. Each item in the range list is interpreted according to the type of the value parameter. String entries are case sensitive. If both value and range are of type string, and value is in the form:
mm/dd/ccyy
then each entry in the range string is interpreted as a date in a similar format. mm/yy is interpreted as mm/01/ccyy if followed by a dash, or mm/31/ccyy if preceded by a dash. The cc value is assumed to be 19 unless specified or unless the SBR=CCYY:## setting in miame.ini has been established.
On return, range is converted into a "compiled" format to eliminate the need for parsing it out on the next call. (If used for file record selection, you would typically be calling this routine hundreds or even thousands of times, with different value parameters but the same (or a limited number of) range strings.
A NULL range string matches all, as does a NULL value (for String ranges). Examples:
Range String |
Meaning |
"AA-CZ,F,JA*" |
Match any string starting with "AA" through "CZ" ("ABCD" matches, "CZ1" does not). Also match if Value = "F", or if it equals anything starting with "JA". |
"91300-91399,93132,95555" |
Match any number 91300 through 91399, or match 93132 or 95555. |
"03/15/97,04/97-2/98,3/02/1999" |
Date match, including Mar 31 1997, or April 1 1997 through Feb 28 1998, or March 2, 1999. |