Compile Error: Labels must appear before a loop

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


Compile Error: Labels must appear before a loop or DefData statement



...any idea's what this means? code in question is a relatively complex nest of if statements with various goto's pointing to this single label. no other labels exist in the project, and as far as i know all syntax is legal...

Function check_particle()
	Const x_less = grid_x - 1
	Const x_plus = grid_x + 1
	Const y_less = grid_y - 1
	Const 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
	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
		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
	Return
End Function