Bug IncludeFile and XIncludeFile?
-
- Addict
- Posts: 1516
- Joined: Wed Nov 12, 2008 5:01 pm
- Location: Russia
Bug IncludeFile and XIncludeFile?
Why is current directory for operators IncludeFile and XIncludeFile does not correspond to directory with the file?
Test code. http://depositfiles.com/files/np3qenm48
Test code. http://depositfiles.com/files/np3qenm48
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Bug IncludeFile and XIncludeFile
Post your code on the forum - that download site is potentially dangerous.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- Addict
- Posts: 4773
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Bug IncludeFile and XIncludeFile
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.
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?
Ask Fred, I would really like to know why he choose to do it this way !User_Russian wrote:Why is current directory for operators IncludeFile and XIncludeFile does not correspond to directory with the file ?
As a workaround, we can do this:
change
Code: Select all
IncludeFile "Inc_2.pbi"
Code: Select all
IncludeFile #PB_Compiler_FilePath + "Inc_2.pbi"
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.

"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: Bug IncludeFile and XIncludeFile?
I made a macro and added it to the compiler as a resident (so no need to include it in the source):luis wrote:It's a little ugly and long to type, but we don't have another choice.Code: Select all
IncludeFile #PB_Compiler_FilePath + "Inc_2.pbi"
Code: Select all
Macro using
XIncludeFile #PB_Compiler_FilePath +
EndMacro
; In the source:
using "myfile.pb"
No problem there either.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
-
- Addict
- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Bug IncludeFile and XIncludeFile?
http://www.purebasic.com/documentation/ ... ludes.html :User_Russian wrote:Why is current directory for operators IncludeFile and XIncludeFile does not correspond to directory with the file?
"IncludePath will specify a default path for all files included after the call of this command."
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Bug IncludeFile and XIncludeFile?
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
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

"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: Bug IncludeFile and XIncludeFile?
I just came across the same issue:
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.
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
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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Bug IncludeFile and XIncludeFile?
Did you see topic Working out Include Path issues?c4s wrote:I just came across the same issue
- 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?
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! 

If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Re: Bug IncludeFile and XIncludeFile?
I never believed in miracles until now. 

"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review