Was this page helpful?

Operator Not Equal

    Table of contents

    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))
     
    Was this page helpful?
    Tag page (Edit tags)
    • No tags
    Page statistics
    2833 view(s), 3 edit(s) and 7077 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments