Page 1 of 1

Retrieve path of MainFile in includeFile [Resolved]

Posted: Mon Jul 28, 2014 6:25 pm
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

Re: Retrieve path of MainFile in includeFile

Posted: Mon Jul 28, 2014 7:21 pm
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$

Re: Retrieve path of MainFile in includeFile

Posted: Mon Jul 28, 2014 8:58 pm
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