Errors, bugs, questions - page 2332

 
Vladimir Pastushak:

According to the help, it should return false if the file does not exist.

Strictly speaking, it does not follow from the documentation that the result of FileGetInteger(FileName,FILE_EXISTS) is necessarily a bool

But the logic is ornate in any case

https://www.mql5.com/ru/forum/1111/page1788#comment_4071879

Ошибки, баги, вопросы
Ошибки, баги, вопросы
  • 2017.02.08
  • www.mql5.com
Общее обсуждение: Ошибки, баги, вопросы
 

The site engine is not highlighting the macro in red.

 
Vladimir Pastushak:

bool file_exists=(bool)FileGetInteger(FileName,FILE_EXISTS);

In any case it returns true if there is file or not, and error 5019 if there is no file. According to help, it should return false if there is no file.

bool file_exists=FileIsExist(FileName); Works correctly

The correct way would be

bool file_exists=FileGetInteger(FileName,FILE_EXISTS)==1; 
 
Vladimir Pastushak:

Got it in mt 5

Please provide code to study, via PM

 
fxsaber:

The website engine does not highlight the macro in red.

It should only be highlighted in red if the macro was previously defined

#define  PRICEST_TICK_PRICE bid
//...
#define PRICEST_TICK_PRICE ask

Otherwise how do you know that a macro has not been defined before?! And it is not an accidental override

Sometimes it even works in MetaEditor:


 
A100:

The colour should only be highlighted if the macro was previously defined

otherwise how do we know that the macro was not previously defined?! and this is not an accidental override

Then we need to define what is a highlighted macro and what is not highlighted?

Thought all macros were highlighted. Apparently the rule is different.

 
fxsaber:

Then we need to decide what is a highlighted macro and what is not highlighted?

I thought all macros were highlighted. Apparently, the rule is different.

I think we need to decide what highlighting is good for, is it just for beauty or informativeness? There are no rules as such at the moment:

In general, it is desirable that if an identifier has already been defined and is not undefended, it should be highlighted in colour

 
A100:

I think we need to decide what the illumination is all about: is it for beauty or for information? There are no rules as such at the moment:

For me, the rule of thumb is: the macro is always red.

 
fxsaber:

For me the rule is convenient: the macro is always red.

What is the convenience here?
#define PRICEST_TICK_PRICE bid

The inconvenience is clear: you can't tell if the PRICEST_TICK_PRICE identifier was previously defined or not

And why should it here (3)

//Ln 240
#define  PRICEST_TICK_PRICE ask //(1)
#undef  PRICEST_TICK_PRICE     //(2)
void OnStart()
{
        int PRICEST_TICK_PRICE; //(3)
}

be red? And if it is not red here (3), why should it be red in (1)?

Handy rule: an identifier is red only if it was previously(!) defined and not undone

 

A100:
А в чем здесь удобство?

I can see that this is a macro. In this case you don't need to see #define laterally.

The inconvenience is clear: it is impossible to understand whether the PRICEST_TICK_PRICE identifier was previously defined or not.

I never tried to determine it by colour. Moreover, if everything is in #ifdef, MQL4 and MQL5 may have different colors. The easiest way is to do ALT+G on the macro name to see if it's there or not.

Handy rule: identifier is red only if previously(!) it was defined

I would be comfortable if the macro is mentioned at least once somewhere in #define, #ifdef, #undef, etc. Even if it's not defined.