Expecting 'EndIf'?!

Blitz3D Forums/Blitz3D Beginners Area/Expecting 'EndIf'?!

Q(Posted 2005) [#1]
I was going through the collision tutorial that came with blitz, and I came across a error doing it myself. Everytime I try to run the code I get the error 'Expecting EndIf'. I don't know why it's doin it, hopefully someone here can help. Here is my code:

Graphics3D 800, 600

Const col_sphere = 1
Const col_cube = 2

SetBuffer BackBuffer()

camera = CreateCamera()
PositionEntity camera, 0, 0, -5

light = CreateLight()

sphere = CreateSphere(12)
PositionEntity sphere, -5, 0, 5
EntityType sphere, col_sphere

cube = CreateCube()
PositionEntity cube, 5, 0, 5
EntityType cube, col_cube

Collisions col_sphere, col_cube, 3, 1

While Not KeyHit(1)

MoveEntity sphere, .1, 0, 0

RenderWorld
UpdateWorld

If EntityCollided (sphere, col_cube) Then
Text, 300, 300, "Collided!"
EndIf

Flip

Wend

End

Thanks in advance for help


Graythe(Posted 2005) [#2]
Should be "End If" - not "EndIf"


Q(Posted 2005) [#3]
I still get the same error after replacing EndIf with End If.


Shambler(Posted 2005) [#4]
No comma after Text

Text  300, 300, "Collided!"



Q(Posted 2005) [#5]
It's always the little things ;)

Thanks for the help guys.


big10p(Posted 2005) [#6]
"EndIf" is fine - I use it all the time. :)


jhocking(Posted 2005) [#7]
For future reference, when this sort of error happens, run with the debugger and/or pay attention to which line the cursor is moved to (the cursor will be moved to the problematic line.)


Graythe(Posted 2005) [#8]
If you cannot see where the cursor is -

Hold down the [control] key and press the [end] key and the line will be highlighted. Thanx to the chap that told me about that.


Sir Gak(Posted 2005) [#9]
Yah, that "End if" error comes up for more things than just the If...Endif commands. Another thing that can trigger it is not having a "WEND" to your "WHILE".

@Graythe: I didn't know that! Thanks for that really useful tip!