At moment in main project I'm defining a constant #INCLUDED=1 and in include files I'm adding
Code: Select all
CompilerIf Defined(INCLUDED,#PB_Constant)=0
;- Test code inserted here...
CompilerEndIfCode: Select all
CompilerIf Defined(INCLUDED,#PB_Constant)=0
;- Test code inserted here...
CompilerEndIf@Perkin: The example you describe seems a little confusing. You say you want the code to be added if compiled on its own but not to be added if it is included in a main project, wouldn't it be the other way around? Why else would you be including it if you didn't want it included?Perkin wrote:but if included from a main project that code is not included
That is the typical way of including code only once or if you want the compiling of it to be optional (by defining or not defining the constant). I would also make the constant unique ('#INCLUDED' seems common and non-distict) so that it is only associated with your test code.Perkin wrote:At moment in main project I'm defining a constant #INCLUDED=1 and in include files I'm addingIs that the correct way to do it or is there another wayCode: Select all
CompilerIf Defined(INCLUDED,#PB_Constant)=0 ;- Test code inserted here... CompilerEndIf

Code: Select all
CompilerIf #PB_Compiler_Debugger
;this code will not be included when you compile your final executable
Debug "Hello test mode"
CompilerEndIf
But if you want to test your code (F5)...xorc1zt wrote:you should use #PB_Compiler_Debugger
Code: Select all
CompilerIf #PB_Compiler_Debugger ;this code will not be included when you compile your final executable Debug "Hello test mode" CompilerEndIf
Code: Select all
Procedure MyTestProc()
MessageRequester("Hey","I am here!")
EndProcedure
CompilerIf #PB_Compiler_Debugger
;this code will not be included when you compile your final executable
Debug "Hello test mode"
MyTestProc()
CompilerEndIfShould read as :Demivec wrote:@Perkin: The example you describe seems a little confusing. You say you want the code to be added if compiled on its own but not to be added if it is included in a main project, wouldn't it be the other way around? Why else would you be including it if you didn't want it included?Perkin wrote:but if included from a main project that code is not included![]()
Code: Select all
Procedure MyTestProc()
MessageRequester("Hey","I am here!")
EndProcedure
Procedure MyTestProc2()
MessageRequester("Hey","I am here as well!")
EndProcedure
CompilerIf Defined(INCLUDED,#PB_Constant)=0
;this code will not be included when you compile your final executable
Debug "Hello test mode"
MyTestProc()
MyTestProc2()
CompilerEndIfSo I should change it to something like #MainProjectCompileDemivec wrote:I would also make the constant unique ('#INCLUDED' seems common and non-distict) so that it is only associated with your test code.
I think you've got that rightBisonte wrote: If you want to test your code, and you ARE NOT compiling the final .exe so the example code is executed...
But the example code should only executed if the "includefile" is a single file to test whats in the include...
not if you included the includefilehuh strange sentences
Code: Select all
Procedure MyTestProc()
MessageRequester("Hey","I am here!")
EndProcedure
Procedure MyTestProc2()
MessageRequester("Hey","I am here as well!")
EndProcedure
CompilerIf Defined(INCLUDED,#PB_Constant)=0
;this code will not be included when you compile your final executable
Debug "Hello test mode"
MyTestProc()
MyTestProc2()
CompilerEndIfCode: Select all
#INCLUDED=1
XIncludeFile "IncTest_include.pbi"
MyTestProc()
The include will be used by a few projects, some using different routines.IdeasVacuum wrote:....would it be OK to just comment-out MyTestProc2 when not in use?
I'll give jaPBe a try, haven't used it for a while.Bisonte wrote:If you want "not included" unused procedures...
jaPBe has a "Cutter" Plugin, that shredder the code to one big file with only the used procedures...
(for the final compile its very useful...)