Try this.
Code: Select all
Structure DOUBLE
high.l
low.l
EndStructure
Procedure Your_Function_That_Returns_Double()
!FLDPI
EndProcedure
Procedure.f CatchDoubleReturn(*x.DOUBLE)
!MOV dword EAX,[ESP]
!FST qword [EAX]
;ProcedureReturn
EndProcedure
Procedure.f Double2Float(*x.DOUBLE)
!MOV dword EAX,[ESP]
!FLD qword [EAX]
;ProcedureReturn
EndProcedure
; Call your function
CallFunctionFast(@Your_Function_That_Returns_Double()) ; call DLL function
Debug CatchDoubleReturn(my.DOUBLE)
; now our double is in 'my'
; PB cant handle doubles directly, so
; lets convert it to float
Debug Double2Float(my)
Doubles are returned in ST(0), so CallFunctionF() and CallFunctionFastF()
would automatically convert it to float - if Fred adds this 1 day.
You should be careful, maybe your DLL returns a pointer to double.
In this case the above doesnt work and you have to do:
*x.DOUBLE = CallFunction....
To work with the DOUBLE variables in PureBasic after you got it
from the DLL, take a look at the
F64 library from freedimension.