Retrieve path of MainFile in includeFile [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Retrieve path of MainFile in includeFile [Resolved]

Post by Kwai chang caine »

Hello at all

Since the 5.30 the behaviour of include have changed.

Code: Select all

- Changed: The way (X)IncludeFile and IncludeBinary works: it's now relative to the file which contains these statements (which is easier to handle)
Then if a MainFile call an includeFile, and in this includeFile i have a relative path, how can i do for retrieve the path of the caller MainFile ? :cry:
Because before, that's works, my includeFile (not in the MainFile folder) call a RES beside the MainFile, and now i have search constant compiler and not found how have this path..

Have a good day
Last edited by Kwai chang caine on Mon Jul 28, 2014 9:01 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Retrieve path of MainFile in includeFile

Post by Little John »

In the main file, use this:

Code: Select all

MainFilePath$ = #PB_Compiler_FilePath
Now you have saved the path of the main file in a variable (a constant can be used as well).

You can access this variable not only in the main file itself, but also in any included file etc. Its value will always be the same.

Code: Select all

Debug MainFilePath$
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Retrieve path of MainFile in includeFile

Post by Kwai chang caine »

Hello LittleJohn :D

Ok, just like that !!! It's a good idea :wink:
I thought FRED have planned this problem, and create a PB constant like #PB_MainFilePath :cry:
Perhaps he read that and adding this option...

Pending i do like you say to me....i can even create my own #PB_MainFilePath :shock:
Like that...KCC have create a very little part of PB, and with this action ...enter in PB TEAM :mrgreen:

Thanks a lot LittleJohn and have a very good night
ImageThe happiness is a road...
Not a destination
Post Reply