Files
mql5-skills/skills/mql5/references/docs/34-standardlibrary/1668-standardlibrary-datastructures-carrayfloat-carrayfloatat.md
T
2026-06-23 21:47:51 +08:00

61 lines
1.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# At
Gets the element from the specified array position.
```
float  At(
   int  pos      // position 
   ) const
```
Parameters
pos
[in]  Position of the desired element in the array.
Return Value
The value of the element - success, FLT_MAX - there was an attempt to get an element from a non-existing position (the last error code is ERR_OUT_OF_RANGE).
Note
Of course, FLT_MAX may be a valid value of an array element. Therefore, always check the last error code after receiving such a value.
Example:
```
//--- example for CArrayFloat::At(int)
#include <Arrays\ArrayFloat.mqh>
//---
void OnStart()
  {
   CArrayFloat *array=new CArrayFloat;
   //---
   if(array==NULL)
     {
      printf("Object create error");
      return;
     }
   //--- add arrays elements
   //--- . . .
   for(int i=0;i<array.Total();i++)
     {
      float result=array.At(i);
      if(result==FLT_MAX && GetLastError()==ERR_OUT_OF_RANGE)
        {
         //--- error reading from array
         printf("Get element error");
         delete array;
         return;
        }
      //--- use element
      //--- . . .
     }
   //--- delete array
   delete array;
  }
```