app runs correctly only with debug

BlitzPlus Forums/BlitzPlus Programming/app runs correctly only with debug

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Thanks for the advice regarding the While loop. However as you expected it didn´t solve the problem.
I will post the complete code below so that anyone can try it out.
Global canw
Global canh
Global t
Global balmax

Type Ball
	Field x#,y#
	Field dx#,dy#
	Field size
	Field tt
	Field r,g,b
End Type


window=CreateWindow("Particle Engine",50,50,700,600)
CreateLabel("Number of particles",ClientWidth(window)/2-140,ClientHeight(window)-30,100,20,window)
textfield1=CreateTextArea(ClientWidth(window)/2-25,ClientHeight(window)-30,50,20,window)
button1=CreateButton("Ok",ClientWidth(window)/2+50,ClientHeight(window)-30,20,20,window)

UpdateWindowMenu window ; This MUST be called after creating your menu!
canvas = CreateCanvas (0, 0, ClientWidth (window), 500, window)
SetGadgetLayout canvas, 1, 1, 1, 1 ; Use zero to leave an edge 'unpinned'...

canh=GadgetHeight(canvas)
canw=GadgetWidth(canvas)

; MAKE BUFFER
SetBuffer CanvasBuffer(canvas)
done=False
timer=CreateTimer(25)
t=0 ;globale variabele om na enige tijd bal te verwijderen
balmax=100 ;maximum aantal ballen of particles

InitBalls(b.ball,balmax)

While done=False
	WaitEvent()
	Select EventID()
	Case $101 ; EventID keydown
		Delete_Balls(b.ball)
		t=0
		InitBalls(b.ball,balmax)
	Case $401 ;EventID gadget action
		If EventSource()=button1 Then ;verander het aantal ballen naar de textfield waarde
		;Stop
			;SetStatusText(window,Str(balmax))
			balmax=TextAreaText(textfield1)
			;Stop
		
		End If
		
	Case $803 ;EventID window close.
		done=True
	Case $2001	;suspend deze applicatie
		While WaitEvent()<>$2002
		Wend
	Case $4001 ; EventID checks when timer is timed out
		Cls
		Place_Ball(b.ball)
		Move_Ball(b.ball)
		FlipCanvas canvas
		t=t+1
		FlushEvents $4001
	End Select
Wend
End


;**************************************** FUNCTIONS *****************************************



Function Create_Ball(b.ball,x#,y#,dx#,dy#,size,tt,r,g,bb)
	b.ball=New Ball
	b\x=x#
	b\y=y#
	b\dx=dx#
	b\dy=dy#
	b\size=size
	b\tt=tt
	b\r=r
	b\g=g
	b\b=bb
End Function

Function InitBalls(b.ball,balmax)
	For i=1 To balmax
		x#=canw/2+Rnd(-5,5)
		y#=canh/2+Rnd(-5,5)
		dx#=Rnd(-5,5)
		dy#=Rnd(-5,5)
		size=Rnd(2,10)
		tt=Rnd(50,200)
		Create_Ball(b.ball,x#,y#,dx#,dy#,size,tt,Rnd(200,255),Rnd(150,200),Rnd(0,10))
	Next
End Function


Function Place_Ball(b.ball)
	For b.ball=Each Ball
		Color b\r,b\g,0
		Oval b\x,b\y,b\size,b\size,1
	Next
End Function

Function Move_Ball(b.ball)
	For b.ball=Each Ball
		b\x=b\x+b\dx
		b\y=b\y+b\dy
		If b\tt<t Then
			Delete b.ball
		End If
	Next
End Function

Function Delete_Balls(b.ball)
	For b.ball=Each Ball
		Delete b
	Next
End Function