Array how work it ??

Back to topics list To post a new topic, please log in or register
avatar
26
faustf 2016.06.03 21: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);
       
     }
     
  }
//+------------------------------------------------------------------+
avatar
Moderator
3427
GumRai 2016.06.04 01: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


avatar
26
faustf 2016.06.04 11:29 #
 

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


avatar
Moderator
3427
GumRai 2016.06.04 13: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?

avatar
26
faustf 2016.06.04 14: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 ???


avatar
Moderator
3427
GumRai 2016.06.04 15: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.
Back to topics list  

To add comments, please log in or register