Instr$ Question

Blitz3D Forums/Blitz3D Beginners Area/Instr$ Question

It appears that the "IF"-command considers everything that isn't "0" as "True".

Try this code:
If 5 Then
	Print "IF-command sees TRUE"
Else
	Print "IF-command sees FALSE"
EndIf


You can experiment with the value ("5" in the example code) and set it to "0" and see what it does to the IF-statement.

The CASE-command is only True if the parameter in an exact match.

As Michael said: Instr returns the position at which your string ("ABC") appears in the string you want it to search in (a$).
Therefore the IF-statement accepts this position (which isn't "0") as True, and the CASE doesn't match the TRUE parameter you've set by the SELECT statement (True = 1).

What you can do with the Select-statement:
a$="AAAABBBBBBBBFFFFFFDDDDDDABCAABB"

Select True
	Case Instr(a$,"ABC") > 0
		End
End Select


This way the CASE-statement chechs the comparison between the value returned by "Instr" and "> 0", which is "True".

[Edit]
It seems that JazzieB had the same idea as I did and we were typing at the same time. lol