XIncludeFile and IncludeFile to search local directory first
XIncludeFile and IncludeFile to search local directory first
I would like to see the XIncludeFile and IncludeFile functions search the directory local to the currently included file first before searching the directory local to the file passed to the compiler.
Trond provided a trick to do this by adding another line but I believe this behavior should be built into these functions. I see no tangible benefit to for these functions to search only the compile file directory.
http://www.purebasic.fr/english/viewtopic.php?p=268111
http://www.purebasic.fr/english/viewtopic.php?t=30504
Trond provided a trick to do this by adding another line but I believe this behavior should be built into these functions. I see no tangible benefit to for these functions to search only the compile file directory.
http://www.purebasic.fr/english/viewtopic.php?p=268111
http://www.purebasic.fr/english/viewtopic.php?t=30504
-
- Addict
- Posts: 4773
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: XIncludeFile and IncludeFile to search local directory f
I don't understand the request. I have files in the same folder as my source
and they're all included just fine like this:
What am I misunderstanding?
and they're all included just fine like this:
Code: Select all
IncludeFile "Name.pb"
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
IncludeFile and XIncludeFile only work with files relative to the main source file passed to the PB compiler (%COMPILEFILE).
All files should work like this by default and only if the file is not found check the directory relative to the main source file:
All files should work like this by default and only if the file is not found check the directory relative to the main source file:
Code: Select all
IncludeFile(#PB_Compiler_File+"\..\"+"Include.pb")
XIncludeFile(#PB_Compiler_File+"\..\"+"Include.pb")
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: XIncludeFile and IncludeFile to search local directory f
And yet I hope to see this added,
Every time I have to do something like:
or
when a
XIncludeFileRelative "..\file.ext"
could make everyone happy.
I don't really see why it was done this way in the first place. It's really counter-intuitive IMHO and make difficult create something you can move to another path or share with anyone (unless you use consistently the tricks mentioned above).
It's something minor since you can fix this way, but adding the command would require really... nothing I guess, so a request is understandable.
Thanks.
Every time I have to do something like:
Code: Select all
IncludePath #PB_Compiler_FilePath
XIncludeFile "..\MyFile.pb"
XIncludeFile "..\MyFile2.pb"
XIncludeFile "..\..\MyFile3.pb"
IncludePath "."
Code: Select all
XIncludeFile #PB_Compiler_FilePath + "..\MyFile.pb"
XIncludeFile #PB_Compiler_FilePath + "..\MyFile2.pb"
XIncludeFile #PB_Compiler_FilePath + "..\..\MyFile3.pb"
XIncludeFileRelative "..\file.ext"
could make everyone happy.
I don't really see why it was done this way in the first place. It's really counter-intuitive IMHO and make difficult create something you can move to another path or share with anyone (unless you use consistently the tricks mentioned above).
It's something minor since you can fix this way, but adding the command would require really... nothing I guess, so a request is understandable.
Thanks.
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: XIncludeFile and IncludeFile to search local directory f
I have no problem backing out of my source directory and going into another using XincludeFile.... Nor do I have a problem navigating deeper into my source directory.. I maintain a "includes" directory where I place common reused code files, so I don't have to move things around, etc.. I thought that was just plain good practice.
What exactly is the benefit here? I have to agree I'm not understanding the request.
What exactly is the benefit here? I have to agree I'm not understanding the request.
Re: XIncludeFile and IncludeFile to search local directory f
The links listed in this thread already explains it, but anyway:
In your program's main include:
xincludefile "c:\dira\dirb\includes\math\math1.pb"
xincludefile "c:\dira\dirb\includes\graph\graph1.pb"
If math1.pb needs to include support1.pb I would like to be able to do (inside math1.pb obviously):
xincludefile "..\support\support1.pb"
Would be nice (and logical) and it will make your include tree easily moveable from place to place and shareable with other people.
But this DOES NOT WORK, because all paths are relative to the main program file.
Same thing if math1.pb tries to include math2.pb by simply using:
xincludefile "math2.pb"
They are both in the same dir, but no sir, because the path it's still relative to the main including file.
IMHO this is really flawed.
[EDIT: THIS REQUEST HAS BEEN IMPLEMENTED]
Code: Select all
c:\dira\dirb\includes
c:\dira\dirb\includes\math\
math1.pb
math2.pb
c:\dira\dirb\includes\support\
support1.pb
support2.pb
c:\dira\dirb\includes\graph\
graph1.pb
graph2.pb
xincludefile "c:\dira\dirb\includes\math\math1.pb"
xincludefile "c:\dira\dirb\includes\graph\graph1.pb"
If math1.pb needs to include support1.pb I would like to be able to do (inside math1.pb obviously):
xincludefile "..\support\support1.pb"
Would be nice (and logical) and it will make your include tree easily moveable from place to place and shareable with other people.
But this DOES NOT WORK, because all paths are relative to the main program file.
Same thing if math1.pb tries to include math2.pb by simply using:
xincludefile "math2.pb"
They are both in the same dir, but no sir, because the path it's still relative to the main including file.
IMHO this is really flawed.
[EDIT: THIS REQUEST HAS BEEN IMPLEMENTED]
Last edited by luis on Fri Feb 01, 2019 12:30 pm, edited 3 times in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
-
- Addict
- Posts: 1675
- Joined: Sun Dec 12, 2010 12:36 am
- Location: Somewhere in the midwest
- Contact:
Re: XIncludeFile and IncludeFile to search local directory f
Ah.. I see what you mean, now.