title: calling function with array parameters in c++ dll from Delphi
body: <p>I'm having trouble calling a function in a c++ dll from delphi.</p>
  
  <p>The c++ function is defined as following</p>
  
  <pre><code>BALL_SCRUB_DLL_API int CALLING_CONVENTION bsl2_ModelBallFlight(float cam_X, 
      float cam_Y, 
      float cam_Z, 
      Ball3d* ball_data_in, 
      int n_balls_in, 
      Ball3d* ball_data_out, 
      int &amp;n_balls_out);
  </code></pre>
  
  <p>The ball struct looks as follows:</p>
  
  <pre><code>  typedef struct 
    { float X;
    float Y;
    float Z;
    float VX;
    float VY;
    float VZ;
    int frame_id;
    int flag;
    } Ball3d;
  </code></pre>
  
  <p>I want to send an array of ball_data_in from my delphi app and the c++ dll will return the same array type but with modified values in ball_data_out.</p>
  
  <p>I have defined a TBall3D record as follows:</p>
  
  <pre><code>TBall3D = record
      X : Single;
      Y : Single;
      Z : Single;
      VX : Single;
      VY : Single;
      VZ : Single;
      Framecount : Integer;
      BallFlag : Integer;
    end;
    PBall3D = ^TBall3D;
    TBall3DArray = array of TBall3D;
    PBall3DArray = ^TBall3DArray;
  </code></pre>
  
  <p>My function declration looks as follows:</p>
  
  <pre><code>  TBSL2_ModelBallFlight = function( const Cam_X, Cam_Y, Cam_Z : Single;
                                      const ball_data_in : PBall3DArray;
                                      const NFramesIn : Integer;
                                      var ball_data_out : PBall3DArray;
                                      const NFramesOut : Integer) : Integer; cdecl;
  </code></pre>
  
  <p>How do i make that call from delphi to the dll? Any help would be highly appreciated.</p>