Page 1 of 1

Nested IncludePath and opening nested (X)IncludeFile

Posted: Thu Dec 15, 2011 3:03 pm
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

Re: Nested IncludePath and opening nested (X)IncludeFile

Posted: Thu Dec 15, 2011 3:49 pm
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.

Re: Nested IncludePath and opening nested (X)IncludeFile

Posted: Thu Dec 15, 2011 7:27 pm
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

Re: Nested IncludePath and opening nested (X)IncludeFile

Posted: Thu Dec 15, 2011 8:05 pm
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