[Implemented] Reserved Constant: #PB_Compiler_IncludeFile

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

[Implemented] Reserved Constant: #PB_Compiler_IncludeFile

Post 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.
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Reserved Constant: #PB_Compiler_IncludeFile

Post 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.
User avatar
KJ67
Enthusiast
Enthusiast
Posts: 218
Joined: Fri Jun 26, 2009 3:51 pm
Location: Westernmost tip of Norway

Re: Reserved Constant: #PB_Compiler_IncludeFile

Post by KJ67 »

+1, this would be useful.
The best preparation for tomorrow is doing your best today.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Reserved Constant: #PB_Compiler_IncludeFile

Post by uwekel »

Me, too!
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Post Reply