Page 1 of 1

Posted: Wed Feb 05, 2003 11:33 pm
by BackupUser
Restored from previous forum. Originally posted by Frankie.

I am just starting off with networking and I need the client to be able to type in the server name and port number. I have it after you type the server name and port number it openconsoles and print what you typed in but it is not doing that. It is never printing the server name and the port number that is should. It is not showing the server name and when it should show the port number it always print 0.So I need help so that it prints out the string and number you type in please help. Here is my following source code.
;////////////////////////////////////////////////////////////////////


InitKeyboard()
InitNetwork()
Procedure Join()
If OpenWindow(0, 270, 100, 250, 200, #PB_Window_MinimizeGadget, "Join Server")
Frame3DGadget(1, 50, 50,100,100, "Server")
CreateGadgetList(WindowID())

TextGadget(0, 48, 10, 200, 20,"Type The Port The Sever Is Using ")
TextGadget(1, 60, 30, 200, 50,"Port Must Between 1 - 16000")
StringGadget(2, 50, 50,160, 20, "")
GadgetToolTip(2, "Port Must Have Server Using It")
TextGadget(3, 50, 80, 200, 50,"Type The Name Of The Server")
StringGadget(4, 50, 100,160, 20, "")
GadgetToolTip(4, "Server Name Must Be Exact")
ButtonGadget(5, 162, 130, 50, 20, "Exit",#PB_Button_Default)
ButtonGadget(6, 50, 130, 50, 20, "Enter",#PB_Button_Default)
Repeat
WaitWindowEvent()
If 5 = EventGadgetID()
End
EndIf
Number = Val(GetGadgetText(2))
If 6 = EventGadgetID() And Number > 16000
MessageRequester("Error", "You Have Inputed A Port Number Greater Than 1600", #PB_MessageRequester_Ok)
StringGadget(2, 50, 50,160, 20, "")

EndIf

Until 6 = EventGadgetID() And Number 0 And Number < 16000
EndIf
EndProcedure
Join()
CloseWindow(0)
ServerName.s
Port.l
ServerName=GetGadgetText(4)

Port=Val(GetGadgetText(2)) + 2


If OpenNetworkConnection(ServerName, Port) = 0
MessageRequester("Error", "Can't Find Server Or IP Inputed Has Periods In It", #PB_MessageRequester_Ok)
OpenConsole()
PrintN(ServerName)
PrintN(Str(Port))
Delay(1000)
Join()
EndIf

Posted: Wed Feb 05, 2003 11:49 pm
by BackupUser
Restored from previous forum. Originally posted by DemonHell.


The variables "ServerName" and "Port" are local to the join() procedure.

Simply add "Global ServerName.s,Port.l" to the top of your code, and the rest of your program can access them.