Autoload Modules

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Autoload Modules

Post by jassing »

It would be nice to standardize on a file extension (ie: .pbm for purebasic module)
And when you issue UseModule MyModule
if mymodule is not already defined, the compiler looks for a file "MyModule.pbm" and includes it auto-magically, before actually acting on the "useModule" command.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Autoload Modules

Post by Danilo »

jassing wrote:It would be nice to standardize on a file extension (ie: .pbm for purebasic module)
And when you issue UseModule MyModule
if mymodule is not already defined, the compiler looks for a file "MyModule.pbm" and includes it auto-magically, before actually acting on the "useModule" command.
Could you compile a macro as resident file, so you can use that feature now?

Code: Select all

Macro DQ
    "
EndMacro

Macro ImportModule(name) ; include and use module
    XIncludeFile #PB_Compiler_Home + "modules/" + DQ#name#DQ + ".pbm"
    UseModule name    
EndMacro

Macro LoadModule(name)   ; include module
    XIncludeFile #PB_Compiler_Home + "modules/" + DQ#name#DQ + ".pbm"
EndMacro

Macro Include(name)      ; include .pbi
    XIncludeFile #PB_Compiler_Home + "includes/" + DQ#name#DQ + ".pbi"
EndMacro


ImportModule(fileModule)

LoadModule(windowModule)

Include(gDrawing)
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: Autoload Modules

Post by Bisonte »

@Danilo: Thanks for this macro. Image
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
Post Reply