Equivalent of userlibs in BlitzMax

BlitzMax Forums/BlitzMax Beginners Area/Equivalent of userlibs in BlitzMax

_33(Posted 2009) [#1]
I've asked this question before but never had an answer (2 years ago). The question was; Is there a simple method to adapt a Blitz3D userlib into a Bmax one?

If there is no simple method, then is there ANY method of doing so?


Gabriel(Posted 2009) [#2]
You just need to link to the DLL, either dynamically with GetProcAddress() or statically with Import (assuming you have a *.a file to link to - if not you can generate one with the GCC tools)

Then you need to convert the DECLS file to a set of declarations for BlitzMax, which basically means putting them in an Extern block. There are dozens of examples around. I'd pick one of Brucey's smaller modules and use that as a guideline.


_33(Posted 2009) [#3]
Thanks Gabriel, then would the following logic work:
Global lib% = LoadLibraryA("win32.dll")
function1 = GetProcAddress(lib,"function1@8")
function2 = GetProcAddress(lib,"function2@8")
function3 = GetProcAddress(lib,"function3@8")


But, I don't see how the parameters work yet...


Gabriel(Posted 2009) [#4]
Yes, that's more or less the dynamic way of linking. You don't need to do anything with the parameters when you assign them. You just need to declare the variables correctly. Turn SuperStrict on, so that you're not tempted to forget.

EG:

Global ThisFunctionSendsTwoInts(First:Int, Second:Int)
ThisFunction=GetProcAddress(lib,"ThisFunctionSendsTwoInts@8")



Ked(Posted 2009) [#5]
_33, note that you need to change the "A" suffix to a "W" since BlitzMax will only support Unicode in future releases. It will still work with the "A", but it would be good to get in the habit of using the "W" (and it will work with Vista and later versions of Windows).


Gabriel(Posted 2009) [#6]
I must have missed the news that BlitzMax is dropping support for single-byte strings in the future. Isn't that going to break a lot of third party modules which use libraries which rely on them?


xlsior(Posted 2009) [#7]
I must have missed the news that BlitzMax is dropping support for single-byte strings in the future. Isn't that going to break a lot of third party modules which use libraries which rely on them?


Don't remember that either -- although versions.txt in Blitzmax 1.34 does state this:
::::: IMPORTANT ::::: This will be the last release to support Win95/98/ME.


But I thought that was more because Win9x doesn't support the unicode stuff natively (it requires an additional DLL that you aren't supposed to bundle with your app), rather than them actively stripping out support for external non-unicode interfaces.


Ked(Posted 2009) [#8]
But I thought that was more because Win9x doesn't support the unicode stuff natively (it requires an additional DLL that you aren't supposed to bundle with your app), rather than them actively stripping out support for external non-unicode interfaces.

Also, Mark said that he didn't want to have to support Unicode and ANSI, too much of a hassle.


Gabriel(Posted 2009) [#9]
But I thought that was more because Win9x doesn't support the unicode stuff natively (it requires an additional DLL that you aren't supposed to bundle with your app), rather than them actively stripping out support for external non-unicode interfaces.

Yes, that's exactly what I thought too.

Also, Mark said that he didn't want to have to support Unicode and ANSI, too much of a hassle.

Well I'm all for removing hassle, but if a load of third party libs stop working, I would have thought that would be hassle for him too. Still, I guess it doesn't affect me much as I don't plan on updating BlitzMax before the release of SST and I was probably going to be using something other than BlitzMax for future games anyway.


theHand(Posted 2009) [#10]
Unicode is more widely accepted as a standard (mainly because of it's support for other languages), which makes it better for the long run; I'm sure that Mark knows this.
Anyway, with the way Microsoft is, they don't care that your applications are broken or anything, they'll just tell you to buy and program for a more recent version of Windows. Case in point: even Windows XP is no longer for sale at Microsoft.com.
Even so, it doesn't look like there will be very many broken usermade libs for this reason. At least, not for WinNT. UTF-8 is supposed to be compatible with CP1252.