简体   繁体   中英

MQL4 - How do I retrieve all values from only one dimension in a 3D Array

As the title suggests, how do I retrieve all values from a single dimension in a multi-dimensional array?

int size = ArraySize(AllLetterPrices);
  for(int i=size-1;i>=0;i--)
  {
      Print(AllLetterPrices[i,Arr_ObjectTRUEPRICE,0]);
  
  }

This returns Array Out Of Range. The index dimension of the Array is dynamic, whereas the second two dimensions are static as follows:

AllLetterPrices[index,0,0];
AllLetterPrices[index,1,0];

Use the following and remember that ArraySize() returns the total number of ALL elements of the array so you cannot use it as you have to count the size of only the first element. Use ArrayRange() instead.

   int size = ArrayRange(AllLetterPrices,0);
   for(int i=size-1; i>=0; i--)
   {
      Print(AllLetterPrices[i][Arr_ObjectTRUEPRICE][0]);
   }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM