New R/BASIC Operators
Published By | Date | Version | Knowledge Level | Keywords |
---|---|---|---|---|
Revelation Technologies | 02 JUN 1992 | 2.1X | INTERMEDIATE | R/BASIC, RBASIC, OPERATORS, CASESENSITIVE, CASE, SENSITIVE |
Advanced Revelation 2.1 introduces six new R/BASIC comparison operators. These operators are intended to be used in situations where a case insensitive comparison is desired.
The operators and their meanings are given in the following table:
Operator | Meaning |
---|---|
_EQC | Equal |
_NEC | Not Equal |
_LTC | Less Than |
_GTC | Greater Than |
_LEC | Less Than or Equal |
_GEC | Greater Than or Equal |
To maintain compatibility with existing programs, the new operators are prefixed with a "_" (underscore). This prevents the compiler from confusing the operator with, for example, a variable called NEC.
The "C" suffix is a reminder that the comparison will be case insensitive.
Using the New Operators
Prior to Advanced Revelation 2.1 you would perform a case-insensitive comparison using code similar to that in Figure 1. Both strings are converted to the same case and then the comparison is done.
Figure 2 demonstrates how the same program is written using one of the new operators.
Note: For information on how comparisons are evaluated, see the section "Comparisons in R/LIST" in the "Changes to R/LIST" chapter of the Advanced Revelation 2.1 Addendum. The discussion applies to both R/LIST and R/BASIC.
Examples
Figure 1
DECLARE SUBROUTINE MSG VAR1 = "Revelation" VAR2 = "ReVelATION" CONVERT @LOWER.CASE TO @UPPER.CASE IN VAR1 CONVERT @LOWER.CASE TO @UPPER.CASE IN VAR2 IF VAR1 = VAR2 THEN MSG("Match", "", "", "") END ELSE MSG("No Match", "", "", "") END
Figure 2
DECLARE SUBROUTINE MSG VAR1 = "Revelation" VAR2 = "ReVelATION" IF VAR1 _EQC VAR2 THEN MSG("Match", "", "", "") END ELSE MSG("No Match", "", "", "") END