Page 2 of 2

Posted: Thu Jan 10, 2008 3:34 am
by Dare
:D

Posted: Thu Jan 10, 2008 12:55 pm
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?

Posted: Thu Jan 10, 2008 1:35 pm
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

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

Posted: Tue Dec 14, 2010 12:05 pm
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.

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

Posted: Tue Dec 14, 2010 1:23 pm
by helpy
The Constant #PB_Compiler_FilePath exists since PB Version 4.30 (16th December 2008)

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

Posted: Tue Dec 14, 2010 1:53 pm
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

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

Posted: Tue Dec 14, 2010 2:28 pm
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