shared for ModulDeclare
Posted: Fri Sep 04, 2015 7:09 pm
I want to use mystuff.pbi in more than one project, but I want to control the code with some constant.
For Example:
mystuff.pbi
When I want to access a constant from outside a module, I can handle this with this, but only for one constant:
My suggestion, expand the share functionality to modules, for example.
I know, that I could use a Common-Modul, but than the definition of the constant can't be near the XIncludeFile.
For Example:
Code: Select all
#MyStuff_ThreadSave=#true
xincludefile "mystuff.pbi"
Code: Select all
CompilerIf Not Defined(MyStuff_ThreadSave,#PB_Constant)
#MyStuff_ThreadSave=#false
CompilerEndIf
CompilerIf MyStuff_ThreadSave
debug "something slow but save"
CompilerElse
debug "something fast and dirty"
CompilerEndif
Code: Select all
#myconstant=1
DeclareModule test
EndDeclareModule
CompilerIf #myconstant
Module test
#myconstant=#True
CompilerElse
Module test
#myconstant=#False
CompilerEndIf
Debug #myconstant
EndModule
Code: Select all
#myconstant=1
DeclareModule test
Shared #myconstant
EndDeclareModule
Module test
Debug #myconstant
EndModule