passing array of doubles to DLL ?

 

I read the article "How to Exhange Data: A DLL for MQL% in 10 Minutes."  I followed the instructions, and now have a working DLL with all the sample functions of the article.  I need to add a new function similar to this one (from the article):

The C++ code:

_DLLAPI void __stdcall fnFillArray(int *arr,const int arr_size)
  {
//--- check for the input parameters
   if(arr==NULL || arr_size<1) return;
//--- fill array with values
   for(int i=0;i<arr_size;i++) arr[i]=i;
  }

 The call from MQL5:

#import "MQL5DLLSamples.dll"
void fnFillArray(int &arr[],int arr_size);
#import

//--- call for the array filling
   int    arr[];
   string result="Array: "; 
   ArrayResize(arr,10);
   
   fnFillArray(arr,ArraySize(arr));
   for(int i=0;i<ArraySize(arr);i++) result=result+IntegerToString(arr[i])+" ";
   Print(result);

 As you can see above, the function in the DLL fills the array like so:

 //--- fill array with values
   for(int i=0;i<arr_size;i++) arr[i]=i;

 The array is filled with values, this is done by C++ DLL project.  Instead, I need MQL5 to initialize an array of doubles, fill it with values, and pass this array to the DLL.  The DLL function receives the array and the values contained inside it.  How would you modify this function to do that?  Does anyone know?  Any help would be greatly appreciated.

 Thank you

Joe
 

 

Fast Dive into MQL5
Fast Dive into MQL5
  • 2012.08.02
  • MetaQuotes Software Corp.
  • www.mql5.com
You have decided to study MQL5 trading strategies' programming language, but you know nothing about it? We have tried to examine MQL5 and MetaTrader 5 terminal from the newcomers' point of view and have written this short introductory article. In this article, you can find a brief idea of the possibilities of the language, as well as some tips on working with MetaEditor 5 and the terminal.
 
oneilljo:

I read the article "How to Exhange Data: A DLL for MQL% in 10 Minutes."  I followed the instructions, and now have a working DLL with all the sample functions of the article.  I need to add a new function similar to this one (from the article):

The C++ code:

 The call from MQL5:

 As you can see above, the function in the DLL fills the array like so:

 The array is filled with values, this is done by C++ DLL project.  Instead, I need MQL5 to initialize an array of doubles, fill it with values, and pass this array to the DLL.  The DLL function receives the array and the values contained inside it.  How would you modify this function to do that?  Does anyone know?  Any help would be greatly appreciated.

 Thank you

Joe
 

 

Never mind guys, I sorted it out!  Stupid quesiton.
 

Not a dumb question. I have the same one :)


What solution did you have?

 
You do exactly as stated, fill the array and pass it. Show us your attempt (using CODE button) and state the nature of your problem.
Reason: