Page 1 of 1
IsInitNetwork()
Posted: Sun Feb 17, 2013 11:55 am
by User_Russian
If the program several times to call the function InitNetwork(), this will result in an error.
When the program consists of separate modules, then we have to somehow check if already invoked the function or not.
Need a function, for example, IsInitNetwork()
Code: Select all
InitNetwork().
If IsInitNetwork()=0
InitNetwork()
EndIf
Re: IsInitNetwork()
Posted: Sun Feb 17, 2013 1:50 pm
by ts-soft
WorkAround:
Code: Select all
CompilerIf Defined(InitNetworkEx, #PB_Procedure) = #False
Procedure InitNetworkEx()
Static IsInit = #False
If Not IsInit
IsInit = InitNetwork()
EndIf
ProcedureReturn IsInit
EndProcedure
Macro InitNetwork()
InitNetworkEx()
EndMacro
CompilerEndIf
InitNetwork()
InitNetwork()
Or in this way:
Code: Select all
Import ""
PB_Network_Objects
EndImport
If Not PB_Network_Objects
InitNetwork()
EndIf
Re: IsInitNetwork()
Posted: Sun Feb 17, 2013 5:09 pm
by skywalk
My network structure includes an InitNetwork Flag, but this is cool.
ts-soft wrote:WorkAround:
Code: Select all
Import ""
PB_Network_Objects
EndImport
If Not PB_Network_Objects
InitNetwork()
EndIf
ts-soft is the King of undocumented PB goodies

Now I need KCC to make me an awesome GIF

Re: IsInitNetwork()
Posted: Sun Feb 17, 2013 5:26 pm
by User_Russian
ts-soft wrote:Import ""
PB_Network_Objects
EndImport
Linker error:
POLINK: error: Unresolved external symbol '_PB_Network_Objects'.
POLINK: fatal error: 1 unresolved external(s).
Re: IsInitNetwork()
Posted: Sun Feb 17, 2013 5:34 pm
by ts-soft
In PB5.10 the objectname is changed, so use this one:
Code: Select all
CompilerIf #PB_Compiler_Version > 500
Macro _NetworkObject_
PB_Server_Objects
EndMacro
CompilerElse
Macro _NetworkObject_
PB_Network_Objects
EndMacro
CompilerEndIf
Import ""
_NetworkObject_
EndImport
If Not _NetworkObject_
InitNetwork()
EndIf
Re: IsInitNetwork()
Posted: Sun Feb 17, 2013 9:39 pm
by uwekel
I do it that way:
Code: Select all
DisableDebugger
InitNetwork()
EnableDebugger
Best regards
Uwe