Consistent method for PB Include and libs

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

Consistent method for PB Include and libs

Post by localmotion34 »

With 4.30B2 out, I am in the process of migrating and updating quite alot of code from previous versions.

Over the years, all my code examples from my writing and the forum have become a total mess, and I am trying to organize them all together.

Additionally, because PB has broken the userlib format a few times, PB users are now switching to releasing .pbi files. This is actually fine with me, but library sets like Nexus have a main include file, which then includes quite a few other .pbi files.

Also, since I have become more proficient with C and ASM, I have been able to make static libs for use with PB. Alot of my code now depends on Libs. So my folders not only have .pb files, but have .lib and .obj littered about.

What I am asking for is a mix of the Japbe setup and something new. I'd like a directory in the main PB folder called "Includes", with subfolders "Static" and "Residents".

Accessing the PB Include folder could be done like Japbe by checking checkboxes which then automatically include the file. OR, a constant called "#PB_Include_Path", #PB_Residents_Path and #PB_StaticLib_Path

Includefile #PB_include_Path +"Droopy.pbi"

Import #PB_StaticLib_Path + "AniGIFlib.lib"

This method would allow any PB user to write .pbi files, ane be COMPLETELY CONSISTENT for ALL PB users when distributing. All users would have to do is put the .pbi file and static libs into the proper directories and just use a single include line. Even if a .pbi file includes other .pbi files in subfolders. Additionally, user can then modify the EDITABLE .pbi files to suit their needs.

EX:

Code: Select all

Includefile #PB_include_Path +"Droopy\Droopy.pbi"

Includefile #PB_Residents_Path +"Droopy\Droopy_Res.pbi"

Import #PB_StaticLib_Path + "GIFlibraries\AniGIFlib.lib"

Procedure This (that.l)

Procedure AniGIFControl(hwnd)
The above .pbi format would let ANYONE get going right away using it without having to modify tons of source lines.

My Biggest problem is that I have 2 workstations and a laptop that I program on where i synchronize my PB folders. When on my laptop, all the paths get waaay screwed up because of different drive letters. With this system above, the Include and LIB paths are FIXED and CONSISTENT.

The whole userlib thing seems to be inefficient anymore. I am asking for a UNIFIED and STANDARD way to setup includes and share workable code.

If not, can there be at least a subforum SPECIFICALLY for userlibs where the community shares, verifies, and validates that a particular lib works with a specific PB version? And after a good bit of users have validated the lib, it could be added to a "trusted" list of userlibs that are certified for use with PB versions. My biggest problem is organization followed by endless testing and checking for userlib functionality.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Consistent method for PB Include and libs

Post by luis »

localmotion34 wrote: My Biggest problem is that I have 2 workstations and a laptop that I program on where i synchronize my PB folders. When on my laptop, all the paths get waaay screwed up because of different drive letters.
I understand this is a personal solution only, but for my use I defined a #PBL_ROOT in a "luis.res" files, and all my sources are using

IncludeFile #PBL_ROOT + "/inc/file1.pbi"
IncludeFile #PBL_ROOT + "/inc/file2.pbi"
Import #PBL_ROOT + "/libs/lib.lib"

and so on

So I need to have only a different "luis.res" file for different installations, and the includes keep working.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

?!

Code: Select all

Debug #PB_Compiler_Home+"Includes\"
Debug #PB_Compiler_Home+"Includes\Residents\"
Debug #PB_Compiler_Home+"Includes\Libs\"
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Rescator wrote:?!

Code: Select all

Debug #PB_Compiler_Home+"Includes"
Debug #PB_Compiler_Home+"Includes\Residents"
Debug #PB_Compiler_Home+"Includes\Libs"
I have used this, but on vista, i can't edit my includes without UAC :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Consider that a "safety" feature for your precious includes,
until freak adds a "Include Directory:" under "Source Directory:" in the IDE Editor preferences ;)
(behavior of includes would not change except that if a include is not found then the IDE looks in the default include path as well)
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Ive always used
Import #PB_Compiler_Home + "\Static Library\"
IncludeFile #PB_Compiler_Home + "\Include\"

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Rescator: Good idea - I'll use that. :D

ts-soft: If you right-click a directory in Program Files, you can set permissions to allow users to modify the contents - this will bypass UAC.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

I use a file Prototypes.pb which includes all other project files with function declarations at the top. The benefit of this is that you will never have to worry about using a function that hasn't been declared because this is always done so before the includes.

Easy as pie. :)
Post Reply