string array doesn't work for mql4

To add comments, please log in or register
Max
17
Max  
//I define the global array.

string m_symbols[FX_GOODS_MAXNUM];

//set the value:

for(int i=0; i<FX_GOODS_MAXNUM;i++)
{
m_symbols[i]="abc";
}

for(int i=0; i<FX_GOODS_MAXNUM;i++)
{
Alert(m_symbols[i]); //print the string array to check the value, nothing is printed
}


Can anyone help me to solve the problem; thanks
OneDay
115
OneDay  
ywang2:
//I define the global array.

string m_symbols[FX_GOODS_MAXNUM];

//set the value:

for(int i=0; i<FX_GOODS_MAXNUM;i++)
{
m_symbols[i]="abc";
}

for(int i=0; i<FX_GOODS_MAXNUM;i++)
{
Alert(m_symbols[i]); //print the string array to check the value, nothing is printed
}


Can anyone help me to solve the problem; thanks

Try this instead:

int start(){
   //I define the global array.
   int   FX_GOODS_MAXNUM   =  4;
   string m_symbols[];                                // leave the array empty as you will add the elements with the loop below

   for(int i=0; i<FX_GOODS_MAXNUM;i++){               // add one element on each iteration of the loop
      m_symbols[i]="abc";
      Print("element number: ",i," = ",m_symbols[i]); // print the result in the experts tab on the client terminal
   }  
   return(0);
}
Max
17
Max  
oneday:

Try this instead:

Thanks, oneday.

It works.

To add comments, please log in or register