Page 1 of 1
Bug IncludeFile and XIncludeFile?
Posted: Tue Jan 08, 2013 3:38 pm
by User_Russian
Why is current directory for operators
IncludeFile and
XIncludeFile does not correspond to directory with the file?
Test code.
http://depositfiles.com/files/np3qenm48
Re: Bug IncludeFile and XIncludeFile
Posted: Tue Jan 08, 2013 5:01 pm
by IdeasVacuum
Post your code on the forum - that download site is potentially dangerous.
Re: Bug IncludeFile and XIncludeFile
Posted: Tue Jan 08, 2013 8:06 pm
by Little John
In addition to what IdeasVacuum wrote:
This is not a bug report. Please post questions like this in the appropriate subforum.
Before calling something a bug (in PureBasic), be sure that you have understood what's going on.
Re: Bug IncludeFile and XIncludeFile?
Posted: Tue Jan 08, 2013 9:13 pm
by luis
User_Russian wrote:Why is current directory for operators IncludeFile and XIncludeFile does not correspond to directory with the file ?
Ask Fred, I would really like to know why he choose to do it this way !
As a workaround, we can do this:
change
to
Code: Select all
IncludeFile #PB_Compiler_FilePath + "Inc_2.pbi"
It's a little ugly and long to type, but we don't have another choice.
Feature Request and discussions about it ->
http://www.purebasic.fr/english/viewtop ... =3&t=35292
And yes, you should have post the code in the forum, no need for a zip for some lines of code, moreover the link will cease to work sooner or later, whilst the code you post here will not.

Re: Bug IncludeFile and XIncludeFile?
Posted: Wed Jan 09, 2013 4:17 am
by Shield
luis wrote:
Code: Select all
IncludeFile #PB_Compiler_FilePath + "Inc_2.pbi"
It's a little ugly and long to type, but we don't have another choice.
I made a macro and added it to the compiler as a resident (so no need to include it in the source):
Code: Select all
Macro using
XIncludeFile #PB_Compiler_FilePath +
EndMacro
; In the source:
using "myfile.pb"
If you need to publish your code somewhere...a quick search and replace and it's done.
No problem there either.
Re: Bug IncludeFile and XIncludeFile?
Posted: Wed Jan 09, 2013 4:26 am
by MachineCode
User_Russian wrote:Why is current directory for operators IncludeFile and XIncludeFile does not correspond to directory with the file?
http://www.purebasic.com/documentation/ ... ludes.html :
"IncludePath will specify a default path for all files included after the call of this command."
Re: Bug IncludeFile and XIncludeFile?
Posted: Wed Jan 09, 2013 12:37 pm
by luis
You are right, IncludePath in the simple case proposed by User_Russian can solve the problem, but it's not a solution for the general case where you want the included files to include other files relative to THEIR position in the tree to make the whole tree structure always working independently from its position in the filesystem and between different computers.
I think you are better off in taking the habit of use #PB_Compiler_FilePath and solve the problem always and once for all.
In any case anyone can always learn this on his own skin the day he will try to make a tree structure a little more complicated than this one

Re: Bug IncludeFile and XIncludeFile?
Posted: Tue May 20, 2014 6:41 pm
by c4s
I just came across the same issue:
Code: Select all
; ... MAIN FILE ...
XIncludeFile "..\include-a.pbi"
; ---
; ... INCLUDE-A FILE ...
XIncludeFile "include-b.pbi" ; Doesn't work because PB is looking for it in the directory of the main file
If you ask me always having to use "
XIncludeFile #PB_Compiler_FilePath+FILENAME" instead of just "
XIncludeFile FILENAME" is a step backward because that's something the compiler can do for us.
By the way, if it's not considered to be a bug I'd say this thread should at least be moved into the feature requests section.
Re: Bug IncludeFile and XIncludeFile?
Posted: Tue May 20, 2014 6:54 pm
by Danilo
c4s wrote:I just came across the same issue
Did you see topic
Working out Include Path issues?
Fred wrote:It can probably changed to be source relative, yes.
Fred wrote:Changed for the next version, optimism can pay !

Re: Bug IncludeFile and XIncludeFile?
Posted: Tue May 20, 2014 7:17 pm
by c4s
Danilo, thanks for the hint. I overlooked that after all the years (I found a couple of rather old threads) it got fixed - just now when I need it. Great!

Re: Bug IncludeFile and XIncludeFile?
Posted: Tue May 20, 2014 10:47 pm
by luis
I never believed in miracles until now.
