Loop doesn't start when not calling Notify ?

BlitzPlus Forums/BlitzPlus Beginners Area/Loop doesn't start when not calling Notify ?

daqx(Posted 2005) [#1]
Hi,

I'm testing B+ right now ;)

I've got a main loop and an other loop in a function. But this second loop just starts when I call Notify before the loop. If I don't call Notify, the loop doesn't start.

What's up there?


CS_TBL(Posted 2005) [#2]
hm.. sofar I can't make cheese of it.. can you post the source?


daqx(Posted 2005) [#3]
Sure I can ;)

; Zeit speichern
	Local time1 = MilliSecs()
	
	; Stream erstellen
	Local udp = CreateUDPStream(ServerPort)
		
	; Request in den Stream schreiben
	WriteByte udp,$FF
	WriteByte udp,$FF
	WriteByte udp,$FF
	WriteByte udp,$FF
	WriteByte udp,$54
	WriteByte udp,$53
	WriteByte udp,$6F
	WriteByte udp,$75
	WriteByte udp,$72
	WriteByte udp,$63
	WriteByte udp,$65
	WriteByte udp,$20
	WriteByte udp,$45
	WriteByte udp,$6E
	WriteByte udp,$67
	WriteByte udp,$69
	WriteByte udp,$6E
	WriteByte udp,$65
	WriteByte udp,$20
	WriteByte udp,$51
	WriteByte udp,$75
	WriteByte udp,$65
	WriteByte udp,$72
	WriteByte udp,$70
	WriteByte udp,$00
	
	Local ServerIP% = INT_IP(IP)
	
	; Nachricht an den Server schicken
	SendUDPMsg(udp,ServerIP,ServerPort)
	
	Local found = 0
	
        ; WHEN NOT DOING THIS NOTIFY,
        ; THE Repeat/Forever LOOP
        ; WILL NOT BE EXECUTED.
	Notify "Klappt"
	
	Repeat
	
		; Überprüfen ob es einen Timeout gibt
		If MilliSecs()-time1 > timeout Then
		
			Return 1
			
		End If
		
		; Überprüfen ob eine Nachricht eingetroffen ist
		If RecvUDPMsg(udp) Then
			
			; TServerList Objekt erstellen
			Local a.TServerList
			
			; Alle TServerList Einträge abfragen
			For a = Each TServerList
			
				; Wenn es schon einen Eintrag für den
				; abzufragenden Server gibt ...
				If a\IP$ = IP$ And a\Port = ServerPort Then
				
					; found = 1
					found = 1
						
					; -1 lesen
					a\server\OK = ReadInt(udp)
							
					; Request auslesen
					a\server\Typ = ReadByte(udp)
							
					; Protokollversion auslesen
					a\server\Version = ReadByte(udp)
							
					; Hostname lesen
					a\server\Hostname = ReadZeroTerminatedString(udp)
							
					; Map lesen
					a\server\Map = ReadZeroTerminatedString(udp)
							
					; Spielverzeichnis lesen
					a\server\GameDirectory = ReadZeroTerminatedString(udp)
							
					; Spielname lesen
					a\server\GameDescription = ReadZeroTerminatedString(udp)
							
					; Spiel ID lesen
					a\server\AppID = ReadShort(udp)
							
					; Anzahl der Spieler lesen
					a\server\NumPlayers = ReadByte(udp)
							
					; MaxSpieler lesen
					a\server\MaxPlayers = ReadByte(udp)
							
					; Anzahl der Bots lesen
					a\server\NumOfBots = ReadByte(udp)
							
					; Server-Typ lesen
					a\server\Dedicated = ReadByte(udp)
							
					; OS lesen
					a\server\OS = ReadByte(udp)
							
					; Password lesen
					a\server\Password = ReadByte(udp)
							
					; Server secure ?
					a\server\Secure = ReadByte(udp)
							
					; Spielversion lesen
					a\server\GameVersion = ReadZeroTerminatedString(udp)
							
					; Gerade gelesene Daten in die Felder eintragen
					SetGadgetText(txtGame,a\server\GameDescription)
					SetGadgetText(txtHost,a\server\Hostname)
					SetGadgetText(txtMap,a\server\Map)
					SetGadgetText(txtSpieler,a\server\NumPlayers + " von " + a\server\MaxPlayers)
					
					If a\server\NumOfBots = 0 Then
					
						SetGadgetText(txtBots,"Keine Bots")
						
					Else
					
						SetGadgetText(txtBots,a\server\NumOfBots + " Bots")
						
					End If
					
					If Chr(a\server\OS) = "l" Then
					
						SetGadgetText(txtOS,"Linux")
						
					ElseIf Chr(a\server\OS) = "w" Then
					
						SetGadgetText(txtOS,"Windows")
						
					End If
					
					If Chr(a\server\Dedicated) = "d" Then
					
						SetGadgetText(txtTyp,"Dedicated")
						
					ElseIf Chr(a\server\Dedicated) = "l" Then
					
						SetGadgetText(txtTyp,"Listen")
						
					ElseIf Chr(a\server\Dedicated) = "h" Then
					
						SetGadgetText(txtTyp,"HLTV")
						
					End If
					
				End If
			
			Next
Forever


Sorry, it looks a bit ... un-organized ;)

There's a Notify directly in front of the Repeat/Forever loop. If I don't call Notify there, the loop won't be executed.


WolRon(Posted 2005) [#4]
Well, it appears that you are missing some code (he EndIf statement) related to this If statment {If RecvUDPMsg(udp) Then}

Did you post all of it? It doesn't appear that it should compile.


daqx(Posted 2005) [#5]
Yes, that could be. I didn't post all the code because then you'd have to read over 300 lines and I don't think all the code is necessary when BB doesn't start a loop ;)

I could zip and upload the whole project if we don't get a solution this way.


daqx(Posted 2005) [#6]
Okay, I found out that it isn't Notify which makes the program work. Delay also works - so I guess the loop ends before I can receive a message from the server ...


daqx(Posted 2005) [#7]
Found that error - works fine now. Thanks!