Self-learning the MQL5 language from scratch - page 33

 
Vladimir Simakov:

And then there are the patterns...

Yeah, there's a ternary operator, too)

From about this path (understanding and knowing how to write it) the developer's way actually begins. IMHO

Are semicolons after curly brackets in enumeration and template functions necessary or is it just for readability?

 
Реter Konow:
That's my point. No need for enumerations and unnecessary syntax now.
What's the terminal API for then? There are a bit more enumerations there than to f... ... and request/result structures and the like are abundant)
 
Реter Konow:
"... but you haven't answered it correctly yet..."

Valeriy has already answered earlier in his script code:

//+------------------------------------------------------------------+
//|                                                            1.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
bool достаточно_времени=true;
bool достаточно_терпения=true;
//---
   if(достаточно_времени && достаточно_терпения)
     {
      Print("я выучу язык MQL 5");
     }
  }
//+------------------------------------------------------------------+

Sincerely, Vladimir.

 
MrBrooklin:

Valeriy has already answered earlier in his script code:

Respectfully, Vladimir.

Yes, this variant is correct in terms of syntax, but it still lacks logic. Yesterday Vasily wrote a lot about functions. This is where they are needed:

bool Sufficient_time = Sufficient_time();

bool Sufficient_time = Sufficient_time();

if(Sufficient_time && Sufficient_patience)Print("I will learn the language!");

else Print ("I won't.");

You have to calculate time and patience before you put them in a condition, not set them as defaults, because the meaning of having a condition disappears - it is always true.
 
Valeriy Yastremskiy:

Is the semicolon and comma after the curly brace in the enumeration and template function mandatory or is it for readability?

A typo. I initially wanted a template object with macro binding, but decided not to make it worse.)

And for enumerations, yes, it is necessary.

 
Реter Konow:
...This is where they are needed:

bool Sufficient_time = Sufficient_time();

bool Sufficient_patience = Sufficient_patience();

if(Sufficient_time && Sufficient_patience)Print("I will learn the language!");

else Print ("I won't.");

Peter, a counter question to you: why in the bool type , which is intended to store boolean values true or false, have you specified sufficiency_time() and sufficiency_patience()?

Sincerely, Vladimir.
 
MrBrooklin:

Peter, a counter question to you: why have you specified sufficiency_time() and sufficiency_patience() inbool type , which is intended to store logical values true or false?

Regards, Vladimir.
Because these are the functions, which need to be written to calculate the real value of variables "Enough_time" and "Enough_patience".

These functions must contain parameter calculations leading to one logical yes/no answer, which they will return in variables. These functions must return the result as a logical true/false value.
 
Реter Konow:
"...Yes, this variant is correct in terms of syntax, but it still lacks logic..."

Now I'm completely confused: why is there no logic, even though the bool type is used, which is needed to store logical values? Please clarify, then, what is no logic?

Regards, Vladimir.

 
MrBrooklin:

Now I'm completely confused: why is there no logic, even though the bool type is used, which is needed to store logical values? Please clarify what there is no logic in?

Respectfully, Vladimir.

Look: you set both variables to true beforehand (before the condition). So they will ALWAYS be true at every start of the script. Why do we need condition then? Is it possible in this program that variables explicitly initialized with true may not be true? - No! Because you have written this value into them and it cannot be changed anywhere in the code.

In this case, the condition is not needed, and neither are the variables themselves, because ALWAYS the result of the script will be the string "I will learn the language".

However, having variable values calculated in additional functions can lead to different combinations of results - one will return true, the other false, or both will return false, or both will return true... In this case, the written condition is justified by possible variations in variable values leading to printing different strings.
 
MrBrooklin:

Now I'm completely confused: why is there no logic, even though the bool type is used, which is needed to store logical values? Please clarify what there is no logic in?

Sincerely, Vladimir.

There is no logic, because these are variables set in the script. They should be either variables set by user via an instance, or derived from functions, which is even more logical.

I.e. the utility of the script should always be there. Just a script displaying text is useless. And with data input this script will tell you if you can learn the language) And with functions, they simply do not exist, they are not written, and if you write, for example, calculation from level of knowledge of mathematics, knowledge of other languages, how much free time, level of desire and ability to remember and function will return True or False based on calculation then usefulness will be more))))