Nested IncludePath and opening nested (X)IncludeFile

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Franky
Enthusiast
Enthusiast
Posts: 213
Joined: Sat Apr 26, 2003 2:58 pm

Nested IncludePath and opening nested (X)IncludeFile

Post by Franky »

Hi there!

1.) IncludeFile and XIncludeFile should always be relative to the File's Path, they are called from, not from the main compiler-File.
Example showing the problem:

Code: Select all

;File Main.pb:
IncludePath "MyFrame/"
  IncludeFile "Frame1/Inc.pb"
IncludePath ""

Code: Select all

;File MyFrame/Frame1/Inc1.pb:
IncludeFile "var.pb" ;How should var.pb know, where it comes from?
A possibility to nest IncludePath would be nice too, perhaps using EndIncludePath to finish this (PB-steady syntax)

2.)

Code: Select all

IncludeFile "Test.pb"
IncludePath "MyFrame/"
  IncludeFile "Frame1/Inc.pb"
IncludePath ""
DoubleClicking on Test.pb gets me to the file (it's opened in the ide)
DoubleClicking on Frame1/Inc.pb doesn't do so, since it's in a subfolder defined by IncludePath. Shouldn't be such a big problem to get this working, should it?

Greetings

Franky
Give Up everything but trying!
xorc1zt
Enthusiast
Enthusiast
Posts: 276
Joined: Sat Jul 09, 2011 7:57 am

Re: Nested IncludePath and opening nested (X)IncludeFile

Post by xorc1zt »

if i remember well, includefile just copy/paste the target file into the current file when you compile your code because purebasic compiler is limited to one file

example

AAA.pb

Code: Select all

define variable.i = 1
BBB.pb

Code: Select all

includefile "AAA.pb"

variable + 1
at the compilation, purebasic just gonna compile BBB.pb which will be transformed like this

Code: Select all

define variable.i = 1 ;AAA.pb copied / pasted

variable + 1
thats why the relative path don't change.

sorry for my poor english.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Nested IncludePath and opening nested (X)IncludeFile

Post by Little John »

Franky wrote:1.) IncludeFile and XIncludeFile should always be relative to the File's Path, they are called from, not from the main compiler-File.
Example showing the problem:

Code: Select all

;File Main.pb:
IncludePath "MyFrame/"
  IncludeFile "Frame1/Inc.pb"
IncludePath ""

Code: Select all

;File MyFrame/Frame1/Inc1.pb:
IncludeFile "var.pb" ;How should var.pb know, where it comes from?
Using #PB_Compiler_FilePath will work as you want:

Code: Select all

;File MyFrame/Frame1/Inc1.pb:
XIncludeFile #PB_Compiler_FilePath + "var.pb"
Regards, Little John
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Nested IncludePath and opening nested (X)IncludeFile

Post by Mistrel »

There was a request for this just four days ago..

http://www.purebasic.fr/english/viewtop ... =3&t=48522


See here for an alternative:

http://www.purebasic.fr/english/viewtop ... =3&t=43921

See here for caveat and suggested fix (posted to bug reports over a year ago)

http://www.purebasic.fr/english/viewtop ... =4&t=44177
Post Reply