tips:revmedia:r84

New R/BASIC Operators

Published ByDateVersionKnowledge LevelKeywords
Revelation Technologies02 JUN 19922.1XINTERMEDIATER/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:

OperatorMeaning
_EQCEqual
_NECNot Equal
_LTCLess Than
_GTCGreater Than
_LECLess Than or Equal
_GECGreater 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.

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.

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
  • tips/revmedia/r84.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1