Is there somethign wrong with this

Blitz3D Forums/Blitz3D Beginners Area/Is there somethign wrong with this

Agamer(Posted 2004) [#1]
Function maininput()
Print"please type a command"
in$=Input()
check()
End Function

Function check()
If Lower$(in$)="start"
startserver()
ElseIf Lower$(in$)="exit"
End
Else
Print"No command found"
EndIf
End Function

is there


Shambler(Posted 2004) [#2]
Yes, the variable in$ is not accessible in the function check().

Either make it a global variable or pass it in the function call.


Agamer(Posted 2004) [#3]
ahh thanks


Agamer(Posted 2004) [#4]
ok I fixed that thanks to your help but I am trying to start a server

Function startserver()

svr=CreateTCPServer(8080)
If svr<>0 Then
Print "Server started successfully."
Else
Print "Server failed to start."
End If
End Function

and it starts it and then says it didn't and then quits


Neo Genesis10(Posted 2004) [#5]
Are you calling the function repeatedly? It may be you're trying to set up multiple servers.


Shambler(Posted 2004) [#6]
Global svr=0


startserver()
startserver()

While Not KeyHit(1)

Wend

Function startserver() 

If svr<>0
Print "Server already started!"
Return
EndIf

 
svr=CreateTCPServer(8080) 
If svr<>0
Print "Server started successfully." 
Else 
Print "Server failed to start." 
End If 

End Function 



Agamer(Posted 2004) [#7]
why do you start the server twice


Shambler(Posted 2004) [#8]
To show you that the second time does not actually start another server it just returns the message "Server already started!"