Page 1 of 1
Shared for Module
Posted: Thu May 18, 2017 6:27 pm
by GPI
sometimes it would be usefull to Share "Resources" from outside of a modul. For example
Code: Select all
#EnableLoging=#true
XIncludeFile "somefile.pbi"
Somefile.pbi
Code: Select all
DeclareModule Some
Shared #EnableLoging
EndDeclareModule
Module some
CompilerIf #EnableLoging
CompilerEndif
EndModule
"Shared" should support in this case Everything (inlcuding Interface, Arrays, Maps, Lists, Variables...)
Re: Shared for Module
Posted: Thu May 18, 2017 7:20 pm
by Sicro
What is bad when using a shared module and to include it in the other modules?
Code: Select all
DeclareModule CommonModule
#test = 123456789
EndDeclareModule
Module CommonModule : EndModule
DeclareModule Whatever
UseModule CommonModule
Declare.i Get()
EndDeclareModule
Module Whatever
Procedure.i Get()
ProcedureReturn #test
EndProcedure
EndModule
DeclareModule Whatever2
UseModule CommonModule
Declare.i Get()
EndDeclareModule
Module Whatever2
Procedure.i Get()
ProcedureReturn #test
EndProcedure
EndModule
Debug Whatever::Get()
Debug Whatever2::Get()
Re: Shared for Module
Posted: Thu May 18, 2017 7:48 pm
by GPI
For example you want to use Code from diffrent users, like here in the "Tricks 'n' Tips" section. One call the Common-Module "Common", other "mCommon" or "CommonModule" that could be a problem. There is no default-name for the "common". Also a Module can only declared once. When you use (as in the example above) more includes with some control-variables, like here
Code: Select all
#something_dothis=#true
xincludefile "Something.pbi"
#this_dothat=#false
xincludefile "this.pbi"
#that_dosomething=#true
xincludefile "that.pbi"
is in my opinion better to read than that:
Code: Select all
DeclareModule Common
#something_dothis=#true
#this_dothat=#false
#that_dosomething=#true
EndDeclareModule
Module Common:EndModule
xincludefile "Something.pbi"
xincludefile "this.pbi"
xincludefile "that.pbi"
The controll constants are then near by the includefiles.