Author Topic: BaCon Comparison Syntax Enhancements  (Read 6140 times)

JRS

  • Guest
BaCon Comparison Syntax Enhancements
« on: February 07, 2011, 12:15:23 AM »
Peter has enhanced the compare syntax in the language to work in a more traditional Basic way.

Quote
Now BaCon has genuine BASIC comparison syntax for both numbers and strings, in addition to the existing ways of comparison. It will be available from build 21.

Number comparison current way:

Code: [Select]
    a = 10
    IF a EQ 10 THEN PRINT "Success"
    IF a NE 10 THEN PRINT "Failed"

Number comparison new way:

Code: [Select]
    a = 10
    IF a = 10 THEN PRINT "Success"
    IF a != 10 THEN PRINT "Failed"

String comparison current way:

Code: [Select]
    a$ = "Hello"
    b$ = "World"
    IF EQUAL(a$, b$) THEN PRINT "Success"
    IF NOT(EQUAL(a$, b$)) THEN PRINT "Failed"

String comparison new way:

Code: [Select]
    a$ = "Hello"
    b$ = "World"
    IF a$ = b$ THEN PRINT "Success"
    IF a$ != b$ THEN PRINT "Failed"

Of course this syntax also works for REPEAT/UNTIL and WHILE/WEND and handles combinations with AND and OR. And as usual OPTION COMPARE determines case sensitive comparison in case of strings.

Regards
Peter
Bacon Project Site