Nesting include files (not really a bug but...)

Just starting out? Need help? Post your questions and find answers here.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:D
Dare2 cut down to size
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

@pdwyer
maybe i don't get it, but trond's example is indeed doing exctly what you want.
put

Code: Select all

IncludePath #PB_Compiler_File + "\.."
XIncludeFile "string.pbi"
into math.pbi, and so for string.pbi is searched in the directory of math.pbi.
the thing is just, that you have to use the trick again when you are back in previous include levels (like a main.pb) if you want to further include files relatively from there. maybe that' the problem what you meant?
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

:oops:

Sorry Trond / #Null

You are indeed right. I assume I know what you meant and didn't test it.

Thanks! -- Time to clean up my includes! :D
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
andrasch
New User
New User
Posts: 9
Joined: Wed Sep 21, 2005 2:43 pm
Location: Germany

Re: Nesting include files (not really a bug but...)

Post by andrasch »

I know, I'm a bit late to contribute to this thread, but I just came about it looking for a solution for the "relative-include-thing" and I find the "IncludePath #PB_Compiler_File" - trick very nice and working fine. I just wanted to add that for me it gets even more handy using a small macro:

Code: Select all

Macro XIncludeFileRelative(FileName)
   XIncludeFile #PB_Compiler_File +  "/../" + FileName
EndMacro
So one doesn't need IncludePath but can just write:

Code: Select all

XIncludeFileRelative("includefile_in_the_same_directory.pb")
To me this looks neat and nice.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re: Nesting include files (not really a bug but...)

Post by helpy »

The Constant #PB_Compiler_FilePath exists since PB Version 4.30 (16th December 2008)
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
andrasch
New User
New User
Posts: 9
Joined: Wed Sep 21, 2005 2:43 pm
Location: Germany

Re: Nesting include files (not really a bug but...)

Post by andrasch »

helpy wrote:The Constant #PB_Compiler_FilePath exists since PB Version 4.30 (16th December 2008)
Hi helpy,
thanks for the info! So the macro should better be like...

Code: Select all

Macro XIncludeFileRelative(FileName)
   XIncludeFile #PB_Compiler_FilePath + FileName
EndMacro
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Nesting include files (not really a bug but...)

Post by Little John »

Very useful! Thanks especially to andrasch and helpy.

I'll just use

Code: Select all

XIncludeFile #PB_Compiler_FilePath + <respective filename>
(w/o a macro), but that's a matter of personal taste.

Regards, Little John
Post Reply