numberMatch()
Checks whether a number falls into a particular range.
Synopsis
bool numberMatch(string pattern, int number);
Parameters
Parameter | Meaning |
---|---|
pattern | pattern |
number | number to be checked |
Return value
The function returns TRUE if the range is correct otherwise, FALSE.
Description
Using the function numberMatch(), you can check whether the number number falls in the range that is described by the pattern pattern. This pattern may consist of any number of digits separated by commas and with or without a sign or number range indication. A number range is defined by the format number1 - number2 whereby number2 must be greater than number1.
Example
The following example checks the correct and incorrect pattern for the number "7".
main()
{
bool isTrue, isFalse;
DebugN(isTrue = numberMatch("1, 3, 6 - 9", 7));
DebugN(isFalse = numberMatch("-9 - -6, -3, -1", 7));
}
Assignment
Miscellaneous functions
Availability
CTRL