Table of contents
- 1. Not Equal
- 1.1. Comparing strings
- 1.2. Comparing integers
Not Equal
In some cases you need to compare a String or Integer to know if they are not the same.
Starting from 7.6, after enabling the new interpreter, you can use the <> operator .
The following are examples of comparing strings and intergers using a function.
Comparing strings
Function
FUNCTION STRCOMP(t1 AS STRING, t2 AS STRING) AS BOOL
IF t1 <> t2 THEN
STRCOMP_1 = FALSE
ELSE
STRCOMP_1 = TRUE
ENDIF
END
//Alternative
FUNCTION STRCOMP_NO(t1 AS STRING, t2 AS STRING) AS BOOL
IF no(t1 = t2) THEN
STRCOMP = FALSE
ELSE
STRCOMP = TRUE
ENDIF
END
Scenario
USE "compare"
DIM t1 AS STRING
DIM t2 AS STRING
t1 = "man"
t2 = "woman"
TraceInfo(t1," Vs. ",t2," => ",STRCOMP_NO(t1,t2))
TraceInfo(t1," Vs. ",t2," => ",STRCOMP(t1,t2))
Comparing integers
Function
FUNCTION INTCOMP(t1 AS INT, t2 AS INT) AS BOOL
IF t1 <> t2 THEN
INTCOMP_1 = FALSE
ELSE
INTCOMP_1 = TRUE
ENDIF
END
//Alternative
FUNCTION INTCOMP_NO(t1 AS INT, t2 AS INT) AS BOOL
IF no(t1 = t2) THEN
INTCOMP = FALSE
ELSE
INTCOMP = TRUE
ENDIF
END
Scenario
USE "compare"
DIM t1 AS INT
DIM t2 AS INT
t1 = 1
t2 = 2
TraceInfo(t1," Vs. ",t2," => ",INTCOMP_NO(t1,t2))
TraceInfo(t1," Vs. ",t2," => ",INTCOMP(t1,t2))
Comments