Error - 'Else' without 'if'

Blitz3D Forums/Blitz3D Beginners Area/Error - 'Else' without 'if'

Jillinger(Posted 2014) [#1]
For the life of me, I cannot figure out why I am getting an error.
Can someone help me out here please.
I keep getting this Error - 'Else' without 'if' on this code:

;Camera mode
If (KeyHit (1)) Then splitScreen = 0
CameraViewport (myCam_01,0,0,screenW,screenH)
Else If (KeyHit (2)) Then splitScreen = 1
CameraViewport (myCamSplit_A,0,0,screenW/2,screenH)
CameraViewport (myCamSplit_B,screenW/2,0,screenW,screenH)
;Else splitScreen = 0 ;I tried this because I got the error 'Else without if'
EndIf


Floyd(Posted 2014) [#2]
The problem here is that "one line If" is a valid construct, without EndIf:

If (KeyHit (1)) Then splitScreen = 0

You probably want something like

If (KeyHit (1))
	splitScreen = 0 
	CameraViewport (myCam_01,0,0,screenW,screenH)
Else If (KeyHit (2))
	splitScreen = 1
	CameraViewport (myCamSplit_A,0,0,screenW/2,screenH)
	CameraViewport (myCamSplit_B,screenW/2,0,screenW,screenH)
EndIf 


And this looks like Blitz3D so I'm moving it.


Jillinger(Posted 2014) [#3]
That seems to work. Thanks, and thanks for replying so quickly.


Hardcoal(Posted 2014) [#4]
by the way use Ideal Editor for your blitz3d code
http://www.fungamesfactory.com/