Download MetaTrader 5
To add comments, please log in or register
Make profit on MQL5 services. It's easy!
macpee
287
macpee 2016.03.25 10:06 
I like to dimension an array and fill it with the product of the respective row indices and column indices. The following are the codes I attempted to write which obviously did not work. Any help from you please?. Thank you in advance.
// I first ininialize my array as follows:
int  ArrayInitialize( 
   int     OrderArray[10,5],     // initialized array 
   int     holder        // value that will be set 
   );



// Secondly, I assigned values to the cells of the array as follows:
void OpenWithArray()
{
for (int i=1;i<=10;i++)
   {
   for (int j=1;j<=10;j++)
      {
      OrderArray[i,j]= i*j;
      Print("Array content for ",i," and ",j," is ",OrderArray[i,j]);
      }
   }      
}
I got the following error message:  'OrderArray' - undeclared identifier
Keith Watford
Moderator
7990
Keith Watford 2016.03.25 10:54  
  int     OrderArray[10,5];

Declared Globalscope


  ArrayInitialize(OrderArray,     // initialized array 
   holder        // value that will be set 
   );

Maybe in init


void OpenWithArray()
{
for (int i=0;i<10;i++)
   {
   for (int j=0;j<5;j++)
      {
      OrderArray[i,j]= i*j;
      Print("Array content for ",i," and ",j," is ",OrderArray[i,j]);
      }
   }      
}

Function

macpee
287
macpee 2016.03.25 12:05  

Thanks @GumRai, the program now works properly.

Next, I realize that each time I read from a file and close the file. The file becomes empty the next time I want to read or write to the file. What mechanism or function can I use to retain the content of the file in order to add to the existing content of the file or read the file again on the next opening of the file. I want the file to retain its content even when I restart the computer. Thank you in advance.

Keith Watford
Moderator
7990
Keith Watford 2016.03.25 12:29  
macpee:

Thanks @GumRai, the program now works properly.

Next, I realize that each time I read from a file and close the file. The file becomes empty the next time I want to read or write to the file. What mechanism or function can I use to retain the content of the file in order to add to the existing content of the file or read the file again on the next opening of the file. I want the file to retain its content even when I restart the computer. Thank you in advance.

The file should not become empty if you are simply reading from it.

As this is not relevant to the thread title, I suggest that you open a new thread and post the code that you are having problems with.

I'm not so good at working with files, so if I can't help you, I am sure that somebody else will and we can both learn something  :)

/
To add comments, please log in or register