Bug IncludeFile and XIncludeFile?

Just starting out? Need help? Post your questions and find answers here.
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Bug IncludeFile and XIncludeFile?

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Bug IncludeFile and XIncludeFile

Post by IdeasVacuum »

Post your code on the forum - that download site is potentially dangerous.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Little John
Addict
Addict
Posts: 4773
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Bug IncludeFile and XIncludeFile

Post 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.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Bug IncludeFile and XIncludeFile?

Post 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

Code: Select all

IncludeFile "Inc_2.pbi"
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. :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Bug IncludeFile and XIncludeFile?

Post 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.
Image
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
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Bug IncludeFile and XIncludeFile?

Post 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."
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Bug IncludeFile and XIncludeFile?

Post 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 :)
"Have you tried turning it off and on again ?"
A little PureBasic review
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Bug IncludeFile and XIncludeFile?

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Bug IncludeFile and XIncludeFile?

Post 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 ! :)
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Bug IncludeFile and XIncludeFile?

Post 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! :)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Bug IncludeFile and XIncludeFile?

Post by luis »

I never believed in miracles until now. :shock:
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply