overload with ArrayBsearch why ?

 

hi guys  i try to search in array bidimentional a string but return me  error


'ArrayBsearch' - no one of the overloads can be applied to the function call    

why ?

int start()
  {
   string nameFile="forexsymbol.csv";
   string terminal_data_path=(TERMINAL_DATA_PATH);
   string filename="forexsymbol.csv";  //
   string line_read[2][416]; //assign array of string that will store 2 columns 416 rows of csv data
   int row=0,col=0; //column and row pointer for the array
   int  handle=FileOpen(filename,FILE_CSV|FILE_READ,";"); //comma delimiter

   if(handle>0)
     {
      while(True) //loop through each cell
        {
         string temp = FileReadString(handle); //read csv cell
         if(FileIsEnding(handle))
            break; //FileIsEnding = End of File
         // Print ("VAVAVAVUBA "+row);
         line_read[col][row]=temp; //save reading result to array
         if(FileIsLineEnding(handle)) //FileIsLineEnding = End of Line
           {
            col = 0; //reset col = 0 for the next row
            row++; //next row
           }
         else
           {
            col++; //next col of the same row
           }
        }
      FileClose(handle);
     }
   else
     {
      Comment("File "+filename+" not found, the last error is ", GetLastError());
     }

   if(guiIsClicked(hwnd,Button1))
     {
      Print("I CHE CE DENTRO "+line_read[1][411]);
      //int dayshift=ArrayBsearch(line_read,StringSubstr(Symbol(),0,3)),WHOLE_ARRAY,0,MODE_DESCEND);
      Print("QUQUQUUQUUQUQUUQ "+ArrayBsearch(line_read,StringSubstr(Symbol(),0,3),WHOLE_ARRAY,0,MODE_DESCEND));
     }

   if(guiIsClicked(hwnd,Button2))
     {
      Print("I CHE CE DENTRO "+line_read[0][411]);
     }


   return  0;
  }



 

Because it doesn't work with strings. Furthermore it searches only in the first dimension of an array if it's multidimensional, that would be the first two columns of your array. And it requires the array to be sorted before. It's all written in the spec.

 
thankz
 

but  why if i use for not print nothing o_O, but if insert number  work

int start()
  {
   string nameFile="forexsymbol.csv";
   string terminal_data_path=(TERMINAL_DATA_PATH);
   string filename="forexsymbol.csv";  //
   string line_read[2][416]; //assign array of string that will store 2 columns 416 rows of csv data
   int row=0,col=0; //column and row pointer for the array
   int  handle=FileOpen(filename,FILE_CSV|FILE_READ,";"); //comma delimiter

   if(handle>0)
     {
      while(True) //loop through each cell
        {
         string temp = FileReadString(handle); //read csv cell
         if(FileIsEnding(handle))
            break; //FileIsEnding = End of File
         // Print ("VAVAVAVUBA "+row);
         line_read[col][row]=temp; //save reading result to array
         if(FileIsLineEnding(handle)) //FileIsLineEnding = End of Line
           {
            col = 0; //reset col = 0 for the next row
            row++; //next row
           }
         else
           {
            col++; //next col of the same row
           }
        }
      FileClose(handle);
     }
   else
     {
      Comment("File "+filename+" not found, the last error is ", GetLastError());
     }

   if(guiIsClicked(hwnd,Button1))
     {
      //Print("I CHE CE DENTRO "+line_read[1][411]);

      for(int i=0; i<=ArraySize(line_read); i++)
        {
          Print("I CHE CE DENTRO- "+line_read[0][i]);

            
        }
     }

   if(guiIsClicked(hwnd,Button2))
     {
      Print("I CHE CE DENTRO "+line_read[0][411]);
     }


   return  0;
  }
 
faustf:
thankz

Please use proper English. This is not Pirate Bay.

faustf:

but  why if i use for not print nothing o_O, but if insert number  work

It's difficult to understand you. "Not print nothing" has no meaning to me. You could type it in your native language and use the translation button.
 

sorry  , i ask why , if i use  this  for

for(int i=0; i<=ArraySize(line_read); i++)
        {
          Print("I CHE CE DENTRO- "+line_read[0][i]);

            
        }

not print nothing , but if i insert 

+line_read[0][411]);

print correct  (only one  but correct )

 

ArraySize

The function returns the number of elements of a selected array.

Please look up your array and count the number of elements. You can also Print(ArraySize(line_read)) to see what it returns. Maybe this explains why it prints nothing after a certain value of i.

If you add #property strict to your code you will see a different behaviour. Always use strict when developing mq4.

 
 for(int i=0; i<=((ArraySize(line_read)/2)-1); i++)
        {
         Print("I CHE CE DENTRO- "+line_read[0][i]);

        }

and  why with this for not print nothing ?


Documentation on MQL5: MQL5 programs / Runtime Errors
Documentation on MQL5: MQL5 programs / Runtime Errors
  • www.mql5.com
The executing subsystem of the client terminal has an opportunity to save the error code in case it occurs during a MQL5 program run. There is a predefined variable _LastError for each executable MQL5 program. Before starting the OnInit function, the _LastError variable is reset...
 

i have created  a  2 dimentional array , string line_read[2][800];

why  start a count to 552 ????? if    i set   a=0  ?????????????

 int a=0;
      for(int i=0; i<=((ArraySize(line_read)/2)-1); i++)
        {
         Print("I CHE CE DENTRO- "+line_read[0][a]+a);
         a++;
        }

2020.07.19 11:36:01.377     EURUSD,M30: I CHE CE DENTRO- 552


o_O

 

i  try to understand  ArraySize , (help book is  very short ), if  i  have 2 dimension array i notice  Arraysize return the  sum of total of 2 dimension  array, but  I can't explain myself  why  in this  cicle  if  i set 417

 for(int i=0; i<=417; i++)
        {
         Print("I CHE CE DENTRO- "+line_read[0][i]);
 
        }

the for instruction work in resoneble manner , but if i  use ArraySize  the count  start to 552 ? o_O

for(int i=0; i<=((ArraySize(line_read)/2)-1); i++)
        {
         Print("I CHE CE DENTRO- "+line_read[0][i]);

        }

anyone can explain me better   ArraySize   in this specific case ?

thankz at all

 

What you are looking for is ArrayRange. Read the help of both ArraySize and ArrayRange to get the picture, and try out the examples on these pages.

The help book is explaining both functions very well (in contrast to other functions where it really falls short), give it a try.