Page 1 of 1

[Implemented] Reserved Constant: #PB_Compiler_IncludeFile

Posted: Tue May 22, 2012 4:05 pm
by Tenaja
I wish we had this. Here are two uses I can immediately think of for it:

Code: Select all

Procedure FancyLibrary(i.i)
	CompilerIf #PB_Compiler_IncludeFile = #False     ; example for debugging
		Debug "Parameter for " + #PB_Compiler_Procedure + ": " + Str(i)
	CompilerEndIf
EndProcedure

CompilerIf #PB_Compiler_IncludeFile = #False
	; example to show a demo of the library in use
	FancyLibrary(123)
CompilerEndIf
As it is, if we want this functionality we have to edit the library Include file to demo it.

Re: Reserved Constant: #PB_Compiler_IncludeFile

Posted: Wed May 23, 2012 5:01 pm
by kenmo
+1

When I write include files, I like to append example code or test code at the bottom. These need to be commented out or CompilerIf'ed out between each test execute versus each inclusion in another project.

It would be nice to simply do something like this:

Code: Select all

; Contents of an include file:
Your Constants Here
Your Structures Here
Your Procedures Here
Etc...

CompilerIf (#PB_Compiler_IncludeFile = #False)
  Your Test/Example Code Here
CompilerEndif
An alternative would be the exact opposite: instead of a constant that indicates whether it is an Included file, a constant that indicates whether it is the "top" or main file being compiled.

Re: Reserved Constant: #PB_Compiler_IncludeFile

Posted: Wed May 23, 2012 5:08 pm
by KJ67
+1, this would be useful.

Re: Reserved Constant: #PB_Compiler_IncludeFile

Posted: Sun May 27, 2012 6:01 pm
by uwekel
Me, too!