Blitz can't find while under wend. But I can.

Community Forums/General Help/Blitz can't find while under wend. But I can.

Elzic(Posted 2014) [#1]
Does anybody know what's going on? here is the apparently offending code, i'm using it to easily draw a grid of squares:

Graphics 800,600
SetBuffer BackBuffer

Dim gridxy(19,19)

While vy < 600
A = A+1
B = B
If B = 0 Then
B = 1
EndIf
xs = xs + 1
vx = -800 + 40*A
vy = -600 + 30*B
gridxy(xs,ys) = (vx),(vy)
If vx > 800 Then
vx = -800
A = 0
B = B+1
ys = ys + 1
EndIf
Wend

I've tried using repeat-until unsuccessfully as well.
I've have been having trouble with If and Then and an error saying that there are too many parameters also.
I'm new to basic, so don't get mad at me if these are just a lot of stupid questions.


Elzic(Posted 2014) [#2]
btw: the code is tabbed, just not on this post, although I have no idea if that makes a difference or not.


Floyd(Posted 2014) [#3]
The cursor points to the real offender, despite the misleading error message.

It's not always easy to find the cursor. If you hold down the shift key and press up-arrow it should highlight at least part of the offending line. In this case it is

gridxy(xs,ys) = (vx),(vy)



RemiD(Posted 2014) [#4]
An example of how to use a 2D dim array :


An example of how to use a While Wend loop :


An example of how to use a Repeat Until loop :


I think you should post in the BlitzPlus forums or in the Blitz3d forums, not in this forum.


dawlane(Posted 2014) [#5]
@Elzic: When it comes to programming you need to follow what's know as the KISS principle.

IF/THEN/ELSE general structure
One line
IF x>800 THEN B=1 ELSE B=0
Multi-line
IF X>800
B=1
ELSE
B=0
ENDIF


The nested (loop within a loop) For/Next in RemiD's example is the simplest solution. Another solution would be to use a custom type to store the x,y coordinates and use a one dimensional array with a quick calculation to get the position. Using a type is more versatile as you can group related data like if the grid location was to hold a image for part of a level.

You should read the wiki for For/Next,While/Wend. The Repeat/Until loop is the same as the While/Wend loop with the only difference being is that the loop is performed at least once. You should also read up on how arrays work, especially their structure.

Drawing a grid using while/wend and Repeat/Until and using Not. You can remove Not and replace the equal sign (=) with a less-than (<)


Same thing but using a custom type