Errors, bugs, questions - page 1513

 

Which is better, from a performance point of view, like this:

  template <typename T>
  void SetProperty( const int id, const T Value, const int Modifier = 0 ) const
  {
    const string sType = typename(T);

    if (sType == "double")
      ::ObjectSetDouble(this.Chart, this.Name, id, Modifier, (double)Value);
    else if (sType == "string")
      ::ObjectSetString(this.Chart, this.Name, id, Modifier, (string)Value);
    else
      ::ObjectSetInteger(this.Chart, this.Name, id, Modifier, (long)Value);

    return;
  }

or by overloading methods?

 
zaskok3:

Which is better, from a performance point of view, like this:

or by overloading methods?

you won't see any difference in terms of performance - both solutions have their place :)
 
coderex:
you won't see a difference in terms of performance - both solutions have a place :)

Thank you! Another question:

What is the point of const fields in a structure? Such structures can't even be passed (compiler swears or stack overflows)?

#property strict 

struct STRUCT
{
  const int Num;
  
  STRUCT( const int iNum = 0 ) : Num(iNum) // Если затереть " = 0", то будет ошибка компиляции: 'STRUCT' - wrong parameters count 
  {
  }
  
/*
// Так получается обойти ошибки компиляции, но на этапе выполнения: Stack overflow   
  STRUCT operator = ( STRUCT &Struct )
  {
    STRUCT Res(Struct.Num);
    
    return(Res);
  }
*/
};

const STRUCT GetStruct( const int Num = 0 )
{
  STRUCT Struct(Num);
  
  return(Struct); // 'return' - not allowed for objects with protected members or inheritance 
}

void OnStart( void )
{
  Print(GetStruct(1).Num);
  
  return;
}


Overloading the assignment operator for structures is actually impossible (it would make sense because of the infinite recursion). So why const fields in a structure then?

 
Karputov Vladimir:

On Windows 10 x64 never encountered this error on 1241 build. After the "Unfold" command, the graphics window unfolds completely, without any holes:

You probably have some settings changed inside your operating system (maybe you're into trimming your operating system's defaults or cleaning the registry or the like...).

When dragging the glass with the mouse, press either "Shift" or "Ctrl" or "Alt" at this point.

My best advice is to write to serviceDesk with detailed description, with own code (which shows ticks), with screenshots.

>> Probably you have changed some settings inside of your operating system (maybe you are keen on cutting standard features of your operating system, or registry cleaning, etc...).

I'm not into that kind of stuff, systems are clean

>> Here I can advise you with detailed description, with your code (which shows tics), with screenshots to make an application to ServiceDesk.

and where is this? i thought this branch is the serwer

 

If I use #include to include an mqh-file that contains something similar into the indicator:

int GetIndicatorBuffers( void )
{
  return(indicator_buffers); // 'indicator_buffers' - undeclared identifier
}

there are no errors at the stage of compilation of the indicator itself. But it occurs with mqh separately (see above).

How can I find the value of this property indicator in MT4, so the compiler won't complain more than once in plugged mqh?

 

I'm trying to ensure the application operating in MQL5 and MQL4 identically.

I suspect that when introducing sinput variables in MQL4, they forgot to add functionsParameterSetRange() andParameterGetRange() to the language.

They appear in MQL4 documentation asParameterSetRange() andParameterGetInput()-https://docs.mql4.com/basis/variables/inputvariables#sinput

but the compiler won't accept them.

Unfortunately, without these functions all the fun of sinput variables is lost.

Input Variables - MQL4 Documentation
Input Variables - MQL4 Documentation
  • docs.mql4.com
Input Variables - MQL4 Documentation - MQL4 Documentation
 
zaskok3:

Thank you! Another question:

What is the point of const fields in a structure? Such structures can't even be passed (compiler swears or stack overflows)?


Overloading the assignment operator for structures is virtually impossible (would make sense because of infinite recursion). So why const fields in a structure then?

Enjoy:

#property strict

struct STRUCT
{
  const int Num;
  
  STRUCT( const int iNum  ) : Num( iNum )
  {
  }
  
  STRUCT( const STRUCT& Struct ) : Num( Struct.Num )
  {
  }
};

const STRUCT GetStruct( const int Num = 0 )
{
  STRUCT Struct( Num );
  return Struct;
}
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   Print( GetStruct(1).Num );
}
//+------------------------------------------------------------------+
 
Koldun Zloy:

Enjoy:

It's nice to get right to the point, thank you! I'm still wondering why I didn't figure it out myself before overloading the constructor, but went into the assignment operator. After all, the solution is obvious!
 

Moved the MT4 terminal folder to another drive. Previously I ran it with the portable key. I did the same thing this time.

The terminal connected to the server at once. In the past when I moved a terminal folder the passwords were not saved - I had to re-enter them. Now (build 950) it doesn't happen.

Is this normal (and only for me)?

 
zaskok3:

What better way, from a performance point of view, is this:

Overloading of course.
Reason: