Enhanced include capabilities

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Enhanced include capabilities

Post by tinman »

- AddIncludePath or similar, for multiple include paths

- The ability to include files from the relative path from where the current file is, for example:

Code: Select all

; filename: foo.pb
IncludePath "c:\"
XIncludeFile "sub_folder\bar.pb"  ; Includes c:\sub_folder\bar.pb
And in that file...

Code: Select all

; filename: bar.pb
XIncludeFile "a_really_important_file.pb" ; Includes c:\sub_folder\a_really_important_file.pb
The current way PB works is to try to include c:\a_really_important_file.pb.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

My idea is: Add a new folder in PureBasic-Directory, for example "Includes". In this directory you can copy all your include files for using in different projects (like UserLibrary directory for your *.lib files):
  • .
    ..
    Catalogs
    Compilers
    Debugger
    Examples
    Includes (New!)
    Library SDK
    PureLibraries
    Residents
    ....
When you include a file now (for example: IncludFile "MyHighresTimer.pbi"), the compiler search for this file with follow priority:
1) Search in the new include directory -> If include not found:
2) Search in the folder adjusted by "IncludePath" -> If include not found:
3) Search in the current directory -> If include not found: Error!

So you have a global include directory and you need not set the include path every time in every project.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

yes we need the include directory(like most languages have). this simple things can make things much easier

but the PB updates should be very carefull not touching user files in that dir
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

You can't include a file such as "./includes/test.pb" ???
Lebostein
Addict
Addict
Posts: 826
Joined: Fri Jun 11, 2004 7:07 am

Post by Lebostein »

Yes, very very useful.

Better to turn around the sequence of priority in my first post:

1) Search in the current directory -> If include not found:
2) Search in the folder adjusted by "IncludePath" -> If include not found:
3) Search in the new PB include directory -> If include not found: Error!

So you can 'overload' a include from the global include directory with a changed include with the same name in the current directory or in the directory adjusted by "IncludePath".
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

or just like in c

include <something> , searches the include dir

include "something" , searches the given path
Post Reply