mql4 ArrayBSearch with false or -1 result

 

Hi folks,

how can i retrive a failed return value for ArrayBSearch ?

i just tried to wrote a wrapped ArrayBSearch Method but "dArray[iIndex * iSize + 0]" is always "0".

How can i acces a undefined array like my paramter "(double dArray[], ...)" ?

int wrappedArraySearch(double dArray[],double dValue,int iCount = WHOLE_ARRAY, int iStart = 0, int iDirection = MODE_ASCEND)
{
   int iIndex = ArrayBsearch(dArray,dValue,iCount,iStart,iDirection);
   int iSize = ArrayDimension(dArray);
      
   if (dArray[iIndex * iSize + 0] == dValue)
   {
      return (iIndex);
   }
   else  
   {
      return (-1);
   }
}
Regards

Nok

 
I have always passed arrays by reference.
 
Nokinger:

i just tried to wrote a wrapped ArrayBSearch Method but "dArray[iIndex * iSize + 0]" is always "0".

How can i acces a undefined array like my paramter "(double dArray[], ...)" ?

  1. dArray[] is a single dimensioned array, so ArrayDimension will ALWAYS return 1
  2. If dArray[iIndex] is always zero, the problem is in your calling code.
  3. Arrays are passed by reference always. I only add the ampersand if the function is going to modify elements as a matter of style.

Reason: