GetInteger

Provides simplified access to the functions of API MQL5 ObjectGetInteger() for properties with integer values (of type bool, char, uchar, short, ushort, int, uint, long, ulong, datetime, color) bound to an instance of the class graphic. この関数の呼び出し方は 2 つあります。

正当性をチェックしないプロパティの値の取得

long  GetInteger(
  ENUM_OBJECT_PROPERTY_INTEGER  prop_id,        // 整数型プロパティの識別子
  int                          modifier=-1      // 修飾子
  ) const

パラメータ

prop_id

[in]  整数型グラフィックプロパティの識別子

modifier=-1

[in]  整数型修飾子(インデックス)

戻り値

成功した場合は整数型のプロパティの値、失敗した場合は 0

正当性をチェックするプロパティの値の取得

bool  GetInteger(
  ENUM_OBJECT_PROPERTY_INTEGER  prop_id,      // 整数型プロパティの識別子
  int                          modifier,    // 修飾子
  long&                        value        // 変数へのリンク
  ) const

パラメータ

prop_id

[in] オブジェクトの整数型グラフィックプロパティの識別子

modifier

[in]  整数型修飾子(インデックス)

value

[out]  整数型プロパティの値を格納する変数への参照

戻り値

成功の場合は true、整数型プロパティが取得できなかった場合は false

例:

//--- CChartObject::GetInteger の例
#include <ChartObjects\ChartObject.mqh>
//---
void OnStart()
 {
  CChartObject object;
  //--- 簡単な方法でチャートオブジェクトの色を取得する
  printf("Objects color is %s",ColorToString(object.GetInteger(OBJPROP_COLOR),true));
  //--- 典型的な方法でチャートオブジェクトの色を取得する
  long color_value;
  if(!object.GetInteger(OBJPROP_COLOR,0,color_value))
    {
    printf("Get integer property error %d",GetLastError());
    return;
    }
  else
    printf("Objects color is %s",color_value);
  for(int i=0;i<object.LevelsCount();i++)
    {
    //--- 簡単な方法でレベルを取得する
    printf("Level %d width is %d",i,object.GetInteger(OBJPROP_LEVELWIDTH,i));
    //--- 典型的な方法でレベルを取得する
    long width_value;
    if(!object.GetInteger(OBJPROP_LEVELWIDTH,i,width_value))
       {
        printf("Get integer property error %d",GetLastError());
        return;
       }
    else
        printf("Level %d width is %d",i,width_value);
    }
 }