Author Topic: Using a Purebasic DLL from Powerbasic - Return LONG Values BYREF  (Read 1087 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1080
  • User-Rate: +30/-4
  • Gender: Male
    • it-berater
In this case we want to return 3 Values "byref" from the Purebasic-32 but written DLL.
On the Purebasic Side it looks like this:

Code: [Select]
ProcedureDLL.l Read_Joystick(No.l,Pad.l,Mode.b,*x,*y,*z)
  Protected.l T01,xr,yr,zr 
    ExamineJoystick(No) 
    If *x
      xr=JoystickAxisX(No,Pad,Mode)
      PokeL(*x,xr)
    Else
      xr=0
    EndIf
   
    If *y
      yr=JoystickAxisY(No,Pad,Mode)
      PokeL(*y,yr)
    Else
      yr=0
    EndIf
   
    If *z
      zr=JoystickAxisZ(No,Pad,Mode)
      PokeL(*z,zr)
    Else
      zr=0
    EndIf   
   T01=JoystickButton(No,1)   
  ProcedureReturn T01
EndProcedure

Code: [Select]
' Sample calling a Purebasic DLL from Powerbasic, returning 4 LONG Values "BYREF"

DECLARE FUNCTION Read_Joystick LIB "XYZ.DLL" ALIAS "Read_Joystick" (BYVAL No AS LONG,BYVAL Pad AS LONG,BYVAL MODE AS BYTE,BYREF x AS LONG,BYREF y AS LONG,BYREF z AS LONG) AS LONG

On the PowerBasic Side we can call directly this function with variables to get the X,Y and Z-Values  of the Joystick with that number.