wixette / isb

Interactive Small Basic (ISB) - Simple scripting language to be embedded in Unity games or shell environments.
https://www.nuget.org/packages/ISB/
Apache License 2.0
24 stars 3 forks source link

Comparing strings always returns true #25

Closed ratkingsminion closed 2 years ago

ratkingsminion commented 2 years ago

In the integration demo, the following code adds a sphere:

If "foo" = "bar" Then
    Game.AddBall(1, 1, 1)
EndIf

Is string comparison supported in ISB, or am I doing something wrong?

wixette commented 2 years ago

Good catch. That's a thing that I forgot to made.

wixette commented 2 years ago

Microsft Small Basic only supports equal/non-equal comparisons for strings:

Equal comparison cases:

"a" = "a" -> true
"a" = "b" -> false
"3" = "3" -> true
"3" = 3 -> true
"3" = "4" -> false
"3" = 4 -> false

As for ">", "<", ..., MSB only supports comparisons between numbers:

"3" > 2 -> true
"3" > "2" -> true
"3" > 4 -> false
"3" > "4" -> false

And fails at string comparisons:

"b" > "a" -> false   // NOT FRIENDLY TO PROGRMMERS
wixette commented 2 years ago

With https://github.com/wixette/isb/pull/26 the string comparisons of ISB behave the same as MSB.