Compile Error: Labels must appear before a loop

BlitzMax Forums/BlitzMax Beginners Area/Compile Error: Labels must appear before a loop

hmm... spotted what i assumed to be the only whoopsy in the project, fixed that and no change was made to the output. can't spot anything else...

whats more worrying though, is i noticed i wasn't running with debug enabled: enabled that and attempted to run. screen went black and mouse or keyboard interaction didn't end execution! all i could do was ctrl+backspace to restart the x server and log back in again... darent run it now lol!

[EDIT]
wasn't a one off, just did it again! appears x is crashing out for some reason, somewhere after mousemove()

current code:

Rem
	Written in BlitzMax 1.08 on GNU Linux.

	AuroraSaver - Aurora northern lights screensaver by Freefornow.co.uk
	Copyright (C) 2005 Richard Grant
	EMail: <email removed for web crawlers>
	Address: <address removed for web crawlers>

	This program is free software; you can redistribute it And/Or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, Or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE.  See the
	GNU General Public License For more details.

	You should have received a copy of the GNU General Public License
	along with this program; If Not, write To the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
EndRem

Framework BRL.glMax2D
Import BRL.Random
Import BRL.StandardIO
Import BRL.System

'Strict

Local width = 400, height = 300, mode = 16

If Not GraphicsModeExists(400, 300, 16) Then
	If GraphicsModeExists(400, 300, 24) Then
		mode = 24
	Else
		width = 800
		height = 600
		If Not GraphicsModeExists(800, 600, 16) Then
			If GraphicsModeExists(800, 600, 24) Then
				mode = 24
			Else
				RuntimeError "Cannot initialise a suitable resolution; Execution has terminated!"
				End
			End If
		End If
	End If
End If

' Global Ints
Global grid_x = 0, grid_y = 0
Global one_fourth_width = width / 4, one_fourth_height = height / 4
Global three_fourth_width = one_fourth_width * 3, three_fourth_height = one_fourth_height * 3
Global half_width = width / 2, half_height = height / 2
Global loops = 0, finished_fading = 0, colour = 0

' Global Strings
Global colour_chosen:String = "g"

' Global Arrays
Global xy_colour:String[width, height], xy_position[width, height]

SeedRnd MilliSecs()

Repeat
	grid_x = Rnd(0, width)
	grid_y = Rnd(0, height)
Until grid_x < one_fourth_width Or grid_x > three_fourth_width Or grid_y < one_fourth_height Or grid_y > three_fourth_height

place_particle()

Graphics width, height, mode

HideMouse()
MoveMouse(half_width, half_height)

While MouseX() = 0 Or MouseY() = 0
Wend

While (GetChar() + MouseHit(1) + MouseHit(2) + MouseHit(3) + MouseZ() = 0) And MouseX() = half_width And MouseY() = half_height
	If loops = 1000 Then
		finished_fading = 1
		For grid_x = 0 To width
			For grid_y = 0 To height
				If xy_position[grid_x, grid_y] > 0 Then
					finished_fading = 0
					If xy_position[grid_x, grid_y] < 6 Then
						xy_position[grid_x, grid_y] = 0
					Else
						xy_position[grid_x, grid_y] = xy_position[grid_x, grid_y] - 5
					End If
					draw_particle()
				End If
			Next
		Next
		If finished_fading = 1 Then
			loops = 0
			Cls
			generate_particle()
		End If
	Else
		loops = loops + 1
		If loops Mod 150 = 0 Then generate_particle()
		For grid_x = 0 To width
			For grid_y = 0 To height
				If xy_position[grid_x, grid_y] = 0 Then
					If Int(Rnd(0, 3)) = 0 Then check_particle()
				Else
					xy_position[grid_x, grid_y] = xy_position[grid_x, grid_y] - 1
					draw_particle()
				End If
			Next
		Next
	End If
	FlushMem
	Flip
Wend
End

Function check_particle()
	Local x_less = grid_x - 1
	Local x_plus = grid_x + 1
	Local y_less = grid_y - 1
	Local y_plus = grid_y + 1
	If grid_x > 0 Then
		If xy_position[x_less, grid_y] > 30 Then
			colour_chosen = xy_colour[x_less, grid_y]
			Goto check_particle_b
		End If
		If grid_y > 0 Then
			If xy_position[x_less, y_less] > 30 Then
				colour_chosen = xy_colour[x_less, y_less]
				Goto check_particle_b
			End If
		End If
		If grid_y < height Then
			If xy_position[x_less, y_plus] > 30 Then
				colour_chosen = xy_colour[x_less, y_plus]
				Goto check_particle_b
			End If
		End If
	End If
	If grid_x < width Then
		If xy_position[x_plus, grid_y] > 30 Then
			colour_chosen = xy_colour[x_plus, grid_y]
			Goto check_particle_b
		End If
		If grid_y > 0 Then
			If xy_position[x_plus, y_less] > 30 Then
				colour_chosen = xy_colour[x_plus, y_less]
				Goto check_particle_b
			End If
		End If
		If grid_y < height Then
			If xy_position[x_plus, y_plus] > 30 Then
				colour_chosen = xy_colour[x_plus, y_plus]
				Goto check_particle_b
			End If
		End If
	End If
	If grid_y > 0 Then
		If xy_position[grid_x, y_less] > 30 Then
			colour_chosen = xy_colour[grid_x, y_less]
			Goto check_particle_b
		End If
	End If
	If grid_y < height Then
		If xy_position[grid_x, y_plus] > 30 Then
			colour_chosen = xy_colour[grid_x, y_plus]
			Goto check_particle_b
		End If
	End If
	Return

	#check_particle_b

	If grid_x > 0 Then
		If xy_position[x_less, grid_y] = 0 Then
			place_particle()
			Return
		End If
		If grid_y > 0 Then
			If xy_position[x_less, y_less] = 0 Then
				place_particle()
				Return
			End If
		End If
		If grid_y < height Then
			If xy_position[x_less, y_plus] = 0 Then
				place_particle()
				Return
			End If
		End If
	End If
	If grid_x < width Then
		If xy_position[x_plus, grid_y] = 0 Then
			place_particle()
			Return
		End If
		If grid_y > 0 Then
			If xy_position(x_plus, y_less) = 0 Then
				place_particle()
				Return
			End If
		End If
		If grid_y < height Then
			If xy_position[x_plus, y_plus] = 0 Then
				place_particle()
				Return
			End If
		End If
	End If
	If grid_y > 0 Then
		If xy_position[grid_x, y_less] = 0 Then
			place_particle()
			Return
		End If
	End If
	If grid_y < height Then
		If xy_position[grid_x, y_plus] = 0 Then
			place_particle()
			Return
		End If
	End If
End Function

Function place_particle()
	xy_position[grid_x, grid_y] = 100
	xy_colour[grid_x, grid_y] = colour_chosen
End Function

Function draw_particle()
	Select xy_colour[grid_x, grid_y]
		Case "g"
			SetColor(0, xy_position[grid_x, grid_y], 0)
		Case "r"
			SetColor(xy_position[grid_x, grid_y], 0, 0)
		Case "y"
			SetColor(xy_position[grid_x, grid_y], xy_position[grid_x, grid_y], 0)
	End Select
	DrawRect(grid_x - 1, grid_y - 1, 2, 2)
End Function

Function generate_particle()
	Repeat
		grid_x = Rnd(0, width)
		grid_y = Rnd(0, height)
	Until grid_x < one_fourth_width Or grid_x > three_fourth_width Or grid_y < one_fourth_height Or grid_y > three_fourth_height
	If xy_position[grid_x, grid_y] = 0 Then
		colour = Rnd(0, 11)
		Select True
			Case colour <= 5
				colour_chosen = "g"
			Case colour >= 6 And colour <=9
				colour_chosen = "r"
			Default
				colour_chosen = "y"
		End Select
		place_particle()
	End If
End Function