"Expecting Wend"
Blitz3D Forums/Blitz3D Programming/"Expecting Wend"| 
 | ||
| I made a small game from the blitz3d manual as a source, and something weird happened. After I finished up the game, I tried to play it and it said "Expecting Wend". I then added wend and it still said the same message. Here's the game. It's small, so it isn't to complicated. Dim skyline(40) For i=0 To 39 skyline(i)=Rnd(18,28) Next If bomb_y bomb_y=bomb_y+1 Else If KeyDown( 57 ) bomb_x=plane_x bomb_y=bomb_y+1 EndIf ;check bomb If bomb_y If bomb_y>=29 bomb_y=0 Else If bomb_y>skyline(bomb_x) ;BOOM1 bomb hits skyline! score=score+5 skyline(bomb_x)=skyline(bomb_x)+30 If skyline(bomb_x)>=29 skyline(bomb_x)=29 score=score+15 EndIf bomb_y=0 EndIf EndIf Graphics 640,480 SetBuffer BackBuffer() Dim skyline(40) For i=0 To 39 skyline(i)=Rnd(18,28) Next plane_x=0 plane_y=1 bomb_x=0 bomb_y=0 While Not KeyHit( 1 ) Delay 75 Cls ;move player plane_x=plane_x+1 If plane_x=40 plane_x=0 plane_y=plane_y+1 EndIf ;move bomb If bomb_y bomb_y=bomb_y+1 Else If KeyDown( 57 ) bomb_x=plane_x bomb_y=plane_y+1 EndIf ;check bomb If bomb_y If bomb_y>=29 bomb_y=0 Else If bomb_y>=skyline(bomb_x) ;boom bomb hits skyline! score=score+5 skyline(bomb_x)=skyline(bomb_x)+30 If skyline(bomb_x)>=29 skyline(bomb_x)=29 score=score+15 EndIf bomb_y=0 EndIf EndIf ;draw runway Color 0,25,0 Rect 0,480-1,640,16 ;draw skyline Color 255,255,0 fir i=0 To 39 Rect i*16,plane_y*16.16.16 EndIf ;draw score Color 255,255,255 Text 0,0,"Score="+score Flip False ;check player If plane_x=20 And plane_y=28 RuntimeError "You Win!" If plane_y>=skyline(plane_x) RuntimeError "you Lose!" Wend Is there a reason why it won't work, or is it a bug? | 
| 
 | ||
| "fir i=1 to 39" ? Also missing a 'next' there. Unmatched loops can throw errors like the one you are seeing at completely unrelated portions of the program... Which is one of the reasons that proper indentation is so important so you don't overlook any of the matching pairs... | 
| 
 | ||
| You seem to have a duff For/Next in there - I can see a 'fir'. EDIT: "xlsior" posted it whilst I was pondering it. | 
| 
 | ||
| It didn't work. It still says "Expecting Wend" | 
| 
 | ||
| You need to close the For with a Next. | 
| 
 | ||
| Your Rect is also duff - you need commas in there. | 
| 
 | ||
| well, I copied this game right out of the manual. I see that I made ALOT of mistakes, so i'm going to retype it. thanks for your help guys. | 
| 
 | ||
| Put code inside (code)(/code) tags but use [] instead of (). And indent your code using tabs. It makes it much easier to see where loop endings should go. :) | 
| 
 | ||
| Here's some corrected code. Not sure if it's doing what it should, but at least it's not throwing errors. Dim skyline(40) For i=0 To 39 skyline(i)=Rnd(18,28) Next If bomb_y bomb_y=bomb_y+1 ElseIf KeyDown( 57 ) bomb_x=plane_x bomb_y=bomb_y+1 EndIf ;check bomb If bomb_y If bomb_y>=29 bomb_y=0 ElseIf bomb_y>skyline(bomb_x) ;BOOM1 bomb hits skyline! score=score+5 skyline(bomb_x)=skyline(bomb_x)+30 If skyline(bomb_x)>=29 skyline(bomb_x)=29 score=score+15 EndIf bomb_y=0 EndIf EndIf Graphics 640,480 SetBuffer BackBuffer() Dim skyline(40) For i=0 To 39 skyline(i)=Rnd(18,28) Next plane_x=0 plane_y=1 bomb_x=0 bomb_y=0 While Not KeyHit( 1 ) Delay 75 Cls ;move player plane_x=plane_x+1 If plane_x=40 plane_x=0 plane_y=plane_y+1 EndIf ;move bomb If bomb_y bomb_y=bomb_y+1 Else If KeyDown( 57 ) bomb_x=plane_x bomb_y=plane_y+1 EndIf ;check bomb If bomb_y If bomb_y>=29 bomb_y=0 ElseIf bomb_y>=skyline(bomb_x) ;boom bomb hits skyline! score=score+5 skyline(bomb_x)=skyline(bomb_x)+30 If skyline(bomb_x)>=29 skyline(bomb_x)=29 score=score+15 EndIf bomb_y=0 EndIf EndIf ;draw runway Color 0,25,0 Rect 0,480-1,640,16 ;draw skyline Color 255,255,0 For i=0 To 39 Rect i*16,plane_y*16,16,16 Next ;draw score Color 255,255,255 Text 0,0,"Score="+score Flip False ;check player If plane_x=20 And plane_y=28 RuntimeError "You Win!" If plane_y>=skyline(plane_x) RuntimeError "you Lose!" Wend | 
| 
 | ||
| I think the first bit isnt needed (duplicated code) - maybe a copy and paste error? Dim skyline(40) For i=0 To 39 skyline(i)=Rnd(18,28) Next If bomb_y bomb_y=bomb_y+1 ElseIf KeyDown( 57 ) bomb_x=plane_x bomb_y=bomb_y+1 EndIf ;check bomb If bomb_y If bomb_y>=29 bomb_y=0 ElseIf bomb_y>skyline(bomb_x) ;BOOM1 bomb hits skyline! score=score+5 skyline(bomb_x)=skyline(bomb_x)+30 If skyline(bomb_x)>=29 skyline(bomb_x)=29 score=score+15 EndIf bomb_y=0 EndIf EndIf | 
| 
 | ||
| Seems like there's more dud code than usable in the original code sample, TaGames. ;-) You're probably better off working with some of the code in the sample folders that came with the Blitz3D download. There's some good examples there that you can learn from, and build on. |