Download MetaTrader 5
To add comments, please log in or register
Register at MQL5.community and leave your comments!
faustf
84
faustf 2016.06.03 19:47 

hi guy

i  try tounderstund  how  use  Array  , i created a  simply  script 

in this  script  i want  insert  a seconds  in  Array and  after print it  , but not  work :D  some one canhelp me ?? thankz


//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
#include <stderror.mqh>
#include <stdlib.mqh>
int p,n,TotalSymbols,MAX=0;
int de=61;
int m=TimeSeconds(TimeCurrent());
int aTimer[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   ArrayResize(aTimer,de+1);
   ArrayInitialize(aTimer,EMPTY_VALUE);
   for(int h=0;h==de;h++)
     {
      aTimer[h]=TimeSeconds(TimeCurrent());
      printf("array[%d] = %G",h,aTimer[h]);
     }

   for(int G=0;G==de;G++)
     {
      int temp=ArrayRange(aTimer,G);
      //--- print
      PrintFormat("dim = %d, range = %d",G,temp);
       
     }
     
  }
//+------------------------------------------------------------------+
Keith Watford
Moderator
7955
Keith Watford 2016.06.03 23:08  
   for(int h=0;h==de;h++)

you probably mean

   for(int h=0;h<de;h++)


   for(int G=0;G==de;G++)
     {
      int temp=ArrayRange(aTimer,G);
      //--- print
      PrintFormat("dim = %d, range = %d",G,temp);
       
     }

I have no idea what you are trying to achieve here

The array is single dimensional, so there is no point in trying to retrieve the size of dimensions that don't exist

faustf
84
faustf 2016.06.04 09:29  

thankz  GumRai the second  for   ,  want  only print  a array  content  ,  how  is possible to do ???

Keith Watford
Moderator
7955
Keith Watford 2016.06.04 11:52  
faustf:

thankz  GumRai the second  for   ,  want  only print  a array  content  ,  how  is possible to do ???


Sorry, I still have no idea what you are trying to do.

Maybe you don't know what ArrayRange() returns? and think that it does something else?

faustf
84
faustf 2016.06.04 12:15  

i want  to do:

take  time

insert  in array

display  the array

yea probably Arrayrange is not correct

, because  return a elements , and i want a content ,  but  how  is possible  display a content of  array ???

Keith Watford
Moderator
7955
Keith Watford 2016.06.04 13:19  
You have already coded a loop to assign values to the array so it is a simple matter to write the same loop but instead of assigning values to the array, you retrieve them.
/
To add comments, please log in or register