How can I use the GetFunction() in Purebasic on Mac?

Just starting out? Need help? Post your questions and find answers here.
dman10001
User
User
Posts: 55
Joined: Mon Feb 25, 2013 3:04 pm

How can I use the GetFunction() in Purebasic on Mac?

Post 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]
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: How can I use the GetFunction() in Purebasic on Mac?

Post 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 :!:
User avatar
mk-soft
Always Here
Always Here
Posts: 6205
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: How can I use the GetFunction() in Purebasic on Mac?

Post by mk-soft »

Please not so loud...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
infratec
Always Here
Always Here
Posts: 7582
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: How can I use the GetFunction() in Purebasic on Mac?

Post by infratec »

:mrgreen: :mrgreen: :mrgreen:

You know the german phrase:
As you call into the forest, it resounds
(Bad english translation :wink: )
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: How can I use the GetFunction() in Purebasic on Mac?

Post 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, ...)
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How can I use the GetFunction() in Purebasic on Mac?

Post 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
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
dman10001
User
User
Posts: 55
Joined: Mon Feb 25, 2013 3:04 pm

Re: How can I use the GetFunction() in Purebasic on Mac?

Post by dman10001 »

Hey Thanks everyone for the help.

Olliv and skywalk got it on the money.
Post Reply