4.0B3: Crash when sending a QWORD (q) to dll.

Just starting out? Need help? Post your questions and find answers here.
spacefractal
User
User
Posts: 17
Joined: Tue Jan 24, 2006 7:05 pm

4.0B3: Crash when sending a QWORD (q) to dll.

Post by spacefractal »

Code: Select all

ProcedureDLL BASS_setPosition(handle.l,secs.l)
  sec.q
  flo.f=1.0
  sec=CallFunction(BASS_ID,"BASS_ChannelSeconds2Bytes",handle,flo) // position in sec
  sec=sec*secs
  CallFunction(BASS_ID,"BASS_ChannelSetPosition",handle,sec) // crash
EndProcedure
Here is the BASS document how to use setposition function (where sec is a QWORD):
  • BOOL WINAPI BASS_ChannelSetPosition(
    DWORD handle,
    QWORD pos
    );
So how can I pass a QWORD with the new type?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Callfunction can't be used for this, you will have to use a prototype to achieve this (or split the quad argument in 2 long, hi/low).
spacefractal
User
User
Posts: 17
Joined: Tue Jan 24, 2006 7:05 pm

Post by spacefractal »

Do you have a plan to support that in the next beta?

Otherwice how do I do with that prototype or split convertning (another workaround)?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

CallFunction() is kept only for backward compatibility, prototypes are much more flexible, so it's the way to go.

Ex:

Code: Select all

Prototype.l BASS_ChannelSetPositionPrototype(a.l, b.q)

BASS_ChannelSetPosition.BASS_ChannelSetPositionPrototype = GetFunction(#id, "BASS_ChannelSetPosition")
BASS_ChannelSetPosition(arg1, arg2)
spacefractal
User
User
Posts: 17
Joined: Tue Jan 24, 2006 7:05 pm

Post by spacefractal »

Got it to work :D, Prototypes is the way to go.

Please update the manual, when you made the 4.0 final. I diddent know about it and have oversaw that thing.

You may want to move this topic to "Coding Questions", if you want.
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Fo you have an example which returns a float but has no parameters ?

I have :-

prototype.f funcP()

func.funcP=getfunction(DLL, "func")

debug func

This will show 0 when the result should be 0.3

What am I doing wrong ?
Paid up PB User !
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you miss the parentheses, you're calling a function here:

Code: Select all

debug func()
dontmailme
Enthusiast
Enthusiast
Posts: 537
Joined: Wed Oct 29, 2003 10:35 am

Post by dontmailme »

Yes, I realise that Fred :), but see below :shock:

Now I have managed to get it to work, I did have the openlbrary, prototype and getfunction in an include file and when I do this it fails when the debug func() is run from the main source with the error.... is not a function etc...

My include file must have a bug!

But it doesn't seem to matter, with or without the () I get the same result, the parenthesis are not required !!! , unless there are parameters to pass.
Paid up PB User !
Post Reply