Page 1 of 1
How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 6:01 am
by dman10001
I'm tying to use the Purebasic Function Code: Select all
GetFunction() with BASS_Init(-1,44100,0,0,0)
on a Mac the right way.
Can you help with this one ?
Is this right ?
Code: Select all
GetFunction(0, "BASS_Init" -1, 44100, 0, 0, 0)
[/size]
Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 8:00 am
by infratec
No, it's wrong!
GetFunction() does not call a function, it gets the address of the function.
You have to read the help

Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 9:21 am
by mk-soft
Please not so loud...
Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 9:38 am
by infratec
You know the german phrase:
As you call into the forest, it resounds
(Bad english translation

)
Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 10:12 am
by Olliv
GetFunction()
CallFunctionFast()
Code: Select all
*FunctionAddress = GetFunction(Library, "BASS_init")
FunctionResult = CallFunctionFast(*FunctionAddress, arg1, arg2, ...)
What it can be simplified with :
CallFunction()
Code: Select all
FunctionResult = CallFunction(Library, "BASS_Init", arg1, arg2, ...)
Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 4:31 pm
by skywalk
Use Prototypes since they support all datatypes.
Code: Select all
;;BOOL BASS_Init(
;; int device, // The device to use... -1 = default device, 0 = no sound, 1 = first real output device
;; DWORD freq, // Output sample rate
;; DWORD flags, // A combination of flags
;; HWND win, // The application's main window... 0 = the current foreground window (use this for console applications)
;; GUID *clsid // Class identifier of the object to create, that will be used to initialize DirectSound... NULL = use default
;;);
PrototypeC.i BASS_Init(device.l, freq.l, flags.l, win.i, *clsid_guid)
BASS_DLL.i = OpenLibrary(#PB_Any, #BASS_DLL_FILENAMEPATH$)
If BASS_DLL ; Define BASS.dll Functions to be used.
Global BASS_Init.BASS.Init = GetFunction(BASS_DLL, "BASS_Init")
;...etc...
EndIf
Re: How can I use the GetFunction() in Purebasic on Mac?
Posted: Fri Feb 15, 2019 4:53 pm
by dman10001
Hey Thanks everyone for the help.
Olliv and skywalk got it on the money.