Problem with Named Pipes

 

Maybe I am misundestanding something.

The example with sending MqlTick info over named pipes made me try adding tho the CNamedPipes mqh class and send a structure of my own design.

Excatly the same code  compiles ok on new MQL4 and code executes. could not fully test functionality on MQL4

compiler error messages:

"outtrade" - invalid parameter for import function

"intrade" - invalid parameter for import function

The complete cnamedpipesIE is also attached


Update:


Code works between two "modern" MQL4 accounts except for the string part  (symbol name) . The doubles and the datetime works ok.


  struct T_Info 
   {
    int    accnt;
    string symbol;
    double price;
    double SL;
    double TP;
    datetime stamp;
   };

and 

int WriteFile(int fileHandle,T_Info &outtrade,int bytes,int &numOfBytes,int overlapped);                <<<< - gives error message as indicated 

int ReadFile(int fileHandle,T_Info &intrade,int bytes,int &numOfBytes,int overlapped);                  <<<< - gives error message as indicated 

and



  //Added Ingvar 
   T_Info            intrade;
   int               T_Info_size;
   bool              ReadT_Info();
   bool              WriteT_Info(T_Info &outtrade);
   bool              readResult;


and corresponding code:

bool CNamedPipe::WriteT_Info(T_Info &outtrade)
  {
   int bytesWritten;
   
   WriteFile(hPipe,outtrade,T_Info_size,bytesWritten,0);
   
   Print("Written!!!");

   return(bytesWritten==T_Info_size);
   
  }

bool CNamedPipe::ReadT_Info()
  {
   int bytesRead;

   ReadFile(hPipe,intrade,T_Info_size,bytesRead,NULL);

   readResult = bytesRead==T_Info_size;
   
   return readResult;
  }






Files:
 

This is not a simple structure. You can't pass it to a DLL. There is probably a bug in mql4.

Simple Structures

Structures that do not contain strings or objects of dynamic arrays are called simple structures; variables of such structures can be freely copied to each other, even if they are different structures. Variables of simple structures, as well as their array can be passed as parameters to functions imported from DLL.

 
angevoyageur:

This is not a simple structure. You can't pass it to a DLL. There is probably a bug in mql4.


Thanks, that probably explains it.

 So I guess I will have to create a translation table  for the symbol names and pass it as an integer instead


Thanks angevoyageur, most helpful.

Basic code works now sending simple structure witk "codifed" symbol name from MQL5 to MQL4.  Several details left to work out

 
ingvar_e:


Thanks, that probably explains it.

 So I guess I will have to create a translation table  for the symbol names and pass it as an integer instead


Thanks angevoyageur, most helpful.

Basic code works now sending simple structure witk "codifed" symbol name from MQL5 to MQL4.  Several details left to work out

Answer from ServiceDesk :

Support Team 2014.02.14 13:35
In the upcoming build, this code compiles without errors (we have allowed passing of strings and string arrays, as well as structures containing strings to DLL). But you should keep in mind that 'string' is a complex type, so passing it is a bit tricky - only via array using StringToCharArray/StringToShortArray functions.