'this is to demonstrate the major malfunctions of the "global scope"
' variables, that have just been checked for a certain condition (if)
' change value inside closed condition
' run this and click a few times into the GraphicsWindow
'no field has to be drawn outside that pattern and pointer has just to
'point at those lightblue squares - nowhere else is told to point than on
'current Field (FD). But how comes it points to Fields that do not exist?
Sub Click
For i = 11 To 99
If i/10 <> Math.Floor(i/10) Then
' during this loop i gets changed by Draw() !
If GraphicsWindow.MouseX >= FD[i][Left] And GraphicsWindow.MouseX <= FD[i][Left] + Fieldsize then
If GraphicsWindow.MouseY >= FD[i][Top] and GraphicsWindow.MouseY <= FD[i][Top] + Fieldsize then
currentField = i
Goto exitClick
EndIf
EndIf
EndIf
EndFor
exitClick:
EndSub
Sub Draw
For i = 11 To 99
If i/10 <> Math.Floor(i/10) Then
' inside this condition i gets changed by Click()!
GraphicsWindow.FillRectangle(FD[i][Left], FD[i][Top], Fieldsize, Fieldsize)
EndIf
EndFor
Shapes.Move(Pointer, FD[currentField][Left] - Fieldspace/2, FD[currentField][Top] - Fieldspace/2)
EndSub