Select

Blitz3D Forums/Blitz3D Beginners Area/Select

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

> Interesting that 'If' is faster, despite all
> that has been said!

Well not really. Think of it like this

If blah then
else
; do blah
endif


In this example only two checks aximum are made. Only first if the first is true. Now look at this.

Select blah
Case 1
Case 2
Case 3
Case 4
Case 5
Case 6
Case 7
End select

If blah=7 then six seperate checks have be made before 7 is reached. SO if you had up to case 100. There are 99 checks before it.
To get around this you would simply order then in the most common order and also split it up.
If blah<25

Select blah
Case 0
Case 1
.
.
Case 24
End select

elseif blah<50

Select blah
Case 25
Case 26
.
.
Case 74
End select

elseif blah<75

;etc

else

;etc

endif


Then you only have a max of 25 checks.
However I wouldn't worry about it too much. It's not as essential these days to maximum searches in games.