OK. I know we have went over this and I have had this figured out but I accidently deleted the working one and... yeah. So here is my troubled code.
I get a MAV error on Next in the main loop. I marked it.
Graphics 400,200,32,2 Global t,msg$,serv,the_name$,the_stream,msg1$,msg2$ Type user Field name$ Field stream End Type Global u.user serv=CreateTCPServer(49494) If serv=0 End EndIf While Not KeyHit(1) t=AcceptTCPStream(serv) If t<>0 msg$=ReadLine(t) If msg$="[LOGIN]" msg$=ReadLine(t) u.user=New user u\name$=msg$ u\stream=t SendServerMessage(Upper$(msg$)+" HAS LOGGED ON") EndIf EndIf For u.user=Each user If Not Eof(u\stream) If ReadAvail(u\stream)>1 msg$=ReadLine(u\stream) If msg$="[MSG]" msg1$=ReadLine(u\stream) msg2$=ReadLine(u\stream) SendUserMessage(msg1$,msg2$) ElseIf msg$="[LOGOFF]" msg$=ReadLine(u\stream) the_stream = u\stream DeleteUser(the_stream) SendServerMessage(Upper$(msg$)+" HAS LOGGED OFF") EndIf EndIf Else the_name$=u\name$ the_stream=u\stream DeleteUser(the_stream) SendServerMessage(Upper$(msg$)+" HAS LOGGED OFF") EndIf Next ;MAV ERROR HERE; Delay 1 Wend CloseTCPServer serv End Function SendServerMessage(txt$) For u.user=Each user If u\stream WriteLine u\stream,"[SERVER]" WriteLine u\stream,txt$ EndIf Next End Function Function SendUserMessage(txt1$,txt2$) For u.user=Each user If u\stream WriteLine u\stream,"[USER]" WriteLine u\stream,txt1$ WriteLine u\stream,txt2$ EndIf Next End Function Function DeleteUser(tstream) For u.user=Each user If u\stream=tstream Then Delete u Exit EndIf Next End Function
I get a MAV error on Next in the main loop. I marked it.