Page 1 of 1

Flag the difference between runs and includes

Posted: Sat Nov 13, 2010 10:04 pm
by blueznl
I don't know exactly how to explain this properly, but here's my attempt (and perhaps it is already possible and I simply dunno how, in which case please accept my apologies.)

I would like to have the option to include / execute part of the code in an include file if it was NOT included... Hmmm. That didn't come out right :-)

Here's what I mean:

1. assume I have an include file whatever.pb(i) and a main source main.pb

2. i want to add some testing routines to whatever.pbi, and if i run [F5] whatever.pbi, it will execute those procedures

3. however, when i run main.pb i do NOT want those routines from whatever.pbi to be run

This way it's easier to maintain and test include files without having to resort to an addtional 'test' file. I hope this makes some sense... (In effect, it could be expanded into module testing, but I'd already be happy with the option above :-))

Re: Flag the difference between runs and includes

Posted: Sat Nov 13, 2010 10:20 pm
by cas
Already possible, i do it in this way: in main.pb i define constant, for example #MAIN and then in whatever.pb(i) use this:

Code: Select all

CompilerIf Defined(MAIN,#PB_Constant)=#False
  ;do testing here, won't be executed if you press F5 on main.pb
CompilerEndIf
I hope i understood you correctly...

Re: Flag the difference between runs and includes

Posted: Sat Nov 13, 2010 10:53 pm
by blueznl
Yeah, that will work.

I'd still rather not have to define anything in the main so the request still stands, but this will do for now :-)

Re: Flag the difference between runs and includes

Posted: Sat Nov 13, 2010 11:01 pm
by cas
Fine, then in main.pb -> Compiler Options-> Constants -> check #PB_Editor_CreateExecutable (or compile/build count) and for other includes don't check this constant. Now you can use CompilerIf Defined(PB_Editor_CreateExecutable,#PB_Constant)=#False in your includes.
Don't now reply with some message in this style: "Yes, but i don't want to check anything in compiler options :) ". :mrgreen:

Re: Flag the difference between runs and includes

Posted: Sun Nov 14, 2010 12:45 pm
by blueznl
Very tempted! :-) (Though frankly, it would be the same thing :-) but hey, I can live with the 'define' check.)