Extend UseModule to accept a file name as 2nd argument

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Extend UseModule to accept a file name as 2nd argument

Post by fsw »

Until now I could do this:

Code: Select all

XIncludeFile "myGUI_3v1.pbi"
to get access to my lib.

With Modules I have to do that:

Code: Select all

XIncludeFile "myGUI_3v1.pbi"
UseModule myGUI
In the future it would be awesome to allow this:

Code: Select all

UseModule myGUI "myGUI_3v1.pbi"
You must have realized by now I'm an lazy old fart :mrgreen:
Thanks for reading.

I am to provide the public with beneficial shocks.
Alfred Hitshock
User avatar
Tombmyst
User
User
Posts: 11
Joined: Thu Jul 04, 2013 2:34 am
Location: Québec

Re: Extend UseModule to accept a file name as 2nd argument

Post by Tombmyst »

Code: Select all

Macro UseModuleLazy(name,file)
	XIncludeFile file
	UseModule name
EndMacro
Do never forget the power of macros!
Tombmyst
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Extend UseModule to accept a file name as 2nd argument

Post by blueb »

fsw wrote: In the future it would be awesome to allow this:

Code: Select all

UseModule myGUI "myGUI_3v1.pbi"
If I am asking to include a PBI file in my program,
I think everything inside the PBI file, such as Modules
should be usable in my program.

That's why I'm including the file in my code.

I shouldn't have to state the obvious. :shock:

blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Extend UseModule to accept a file name as 2nd argument

Post by luis »

blueb wrote: If I am asking to include a PBI file in my program,
I think everything inside the PBI file, such as Modules
should be usable in my program.
That's why I'm including the file in my code.
I shouldn't have to state the obvious. :shock:
Considering there are two ways to access a module: UseModule and "nameofthemodue::object" and the fact they have very different implications the idea of always applying a "UseModule" to every module included it's a very bad one.
There are more reasons, but this is enough already. :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply