Problem with declaration without type

 

Hi,

Why when I tried to copy something working into another EA‌... It doesn't work.

Please Help.‌

It says 'SplitString' and 'ArraySize' - declaration without type.

But it is coded like this into many EAs.


int init()  

SplitString(PipsDeclencheur,";", PipsDeclencheurArray);
   SplitString(StopLossToSet,";", StopLossArray);
  
   int maxSize = ArraySize(PipsDeclencheurArray);
   ArrayResize( PipsDeclencheurArrayValue, maxSize);
   ArrayResize( StopLossArrayValue, maxSize);

At the end of the EA, I have this function:


bool SplitString(string stringValue, string separatorSymbol, string& results[], int expectedResultCount = 0) {
   if (StringFind(stringValue, separatorSymbol) < 0) {
      ArrayResize(results, 1);
      results[0] = stringValue;
   } else {  
      int separatorPos = 0;
      int newSeparatorPos = 0;
      int size = 0;

      while(newSeparatorPos > -1) {
         size = size + 1;
         newSeparatorPos = StringFind(stringValue, separatorSymbol, separatorPos);
        
         ArrayResize(results, size);
         if (newSeparatorPos > -1) {
            if (newSeparatorPos - separatorPos > 0) {
               results[size-1] = StringSubstr(stringValue, separatorPos, newSeparatorPos - separatorPos);
            }
         } else {
            results[size-1] = StringSubstr(stringValue, separatorPos, 0);
         }
         separatorPos = newSeparatorPos + 1;
      }
   }  
  
   if (expectedResultCount == 0 || expectedResultCount == ArraySize(results)) {
      return (true);
   } else {
      return (false);
   }
}‌

 

Frenchytrader: It says 'SplitString' and 'ArraySize' - declaration without type. But it is coded like this into many EAs.

int init()  
‌ {
   SplitString(PipsDeclencheur,";", PipsDeclencheurArray);
   SplitString(StopLossToSet,";", StopLossArray);
  
   int maxSize = ArraySize(PipsDeclencheurArray);
   ArrayResize( PipsDeclencheurArrayValue, maxSize);
   ArrayResize( StopLossArrayValue, maxSize);
   :
}
Because no EA is coded like that. Missing open/close braces.
 
As it seems to be a quite old mt4 code snippet what about replacing the function by StringSplit() (which is now available!)?