My approach. The core is the engine. - page 97

 
Vasiliy Sokolov:

Peter, what the hell are strings?! You have a bunch of parameters like double, int, color you convert them to a string to write them into the object on the chart. But you don't need any strings when working with union. Look at the example again, there you are working directly with double, without any strings, and the data are nicely passed.

Vasiliy, in addition to numerical data, the custom EAs set a lot of string data in the engine. Names, messages, etc. Therefore, it is impossible to do only with numbers.

For example, Oleg Papkov's Expert Advisor will pass texts like "The trend went up, the trend went down..." in its windows. Others will want to pass texts in the table cells. Into input fields.

There is no way to do only with numbers... ((

 

If you need to pass text, then translate the string into an array of bytes:

StringToCharArray("text", u.char);

where u is union and u.char array char[] respectively. The union array will have a fixed size, so if the string does not fit then either increase u.char or pass the string in parts.

 
Vasiliy Sokolov:

If you need to pass text, then translate the string into an array of bytes:

where u is union and u.char array char[] respectively. The union array will have a fixed size, so if the string doesn't fit in, either expand u.char or pass the string in parts.

I see. Thanks. I will try it now. (Although, I could just do everything through the object description ). But I want to fully understand the resources. It may come in handy too.

Additional features are always useful. And some new knowledge won't hurt either...

In short, thank you very much for your help personally and everyone else.

 
Реter Konow:

I see. Thank you. I'll give it a try. (Although, you could just do everything through the description of objects ), but I want to get to the bottom of resources. It may come in handy too.

Additional features are always useful. And some new knowledge won't hurt either...

In short, thank you very much for your help personally and everyone else.

If you want fast communication, you can do nothing faster. The string with parameters you'll pass through the objects very quickly, maybe even faster than ResourceCreate, but the parsing of this string will kill all your speed. But MQL is a very fast language, and even slow parsing is relatively fast here.

 
Vasiliy Sokolov:

If you want fast communication, you can't do anything faster than union. You can pass a string with parameters through objects really fast, maybe even faster than ResourceCreate, but the parsing of this string will kill your speed. But MQL is a very fast language, and even slow parsing is relatively fast here.

The problem is that parsing will be needed in any case. After all, even after writing the string into the resource, it must then be extracted from there, collected and then split into parts"parameter number/parameter value".

That is, you can hardly get the broken strings from the resource at once. And therefore parsing is still needed...((

 
Реter Konow:

The problem is that parsing will be needed in any case. After all, even after writing a string to the resource, it must then be extracted from there, collected, and then split into parts"parameter number / parameter value".

That is, you can hardly get the broken strings from the resource at once. So we still need parsing...((

Peter, you're doing it again. How many times has it gone on? It's been already said many times: you pass values and parameter numbers without using strings. In your example you passed and got double without any string parsing. So why are you trying to put this double into a string again? If you need to pass a message to a user - you pass it as text without any parsing. That's it.

 
Vasiliy Sokolov:

Peter, you're at it again. How many times has it been said? It has been said many times: you pass and receive parameter values and numbers WITHOUT using strings. In your example you passed and got double without any string parsing. So why are you trying to put this double into a string again? If you need to pass a message to a user - you pass it as text without any parsing. That's it.

Vasily, let me try to explain.

Parameter values are not only numbers. A parameter value can be a text. For example, a user has entered text into the input field. This text is transferred from the engine to the Expert Advisor. Or, the Expert Advisor sends a text to the GUI at a specific event, with the message " A trading session has started!

Since on each event, the Expert Advisor or the engine needs to pass back and forth data of ALL types (int, double, long, string...), it is more convenient to pass everything in one way, through a string, and then cast to the desired type.

Otherwise, one way to pass some data, and other way to pass other data.

No one knows what data the user will transfer or receive more. Maybe it will be texts that will be the main data. From all sides, it turns out that the string, is a universal medium for transmitting and receiving information.

 
Vasiliy Sokolov:


By the way, check out what a step forward I've made thanks to our solutions yesterday (and your help):

In this particular example, everything is passed through a resource.



And it's all done through this code in the EA:

void OnTimer()
  { 
   static int q1,q2,q3,a,b,c,d; 
   //------------------------------------
   LOAD_CANVAS_Last_10_bars();
   //---------------------------------
   if(!a) { q1++;}
   if(q1 == 200)a = 1;
   if(a)q1--;
   if(!q1)a = 0;
   //------------------------------------  
   CIRCLE(q1,q2,q3,clrGreen);  
   TRIANGLE(q1,q1,q1 + 100,q1 + 10,q1 + 50,q1 + 200,clrRed);  
   ELLIPSE(q1,q1,q1 + q1*2,q1 +  q1,clrBlue);  
   FILLED_CIRCLE(q1,20,20,clrBlue); 
   TRIANGLE(q1 + 10,q1,q1 + 10,q1 + 100,q1 + 50,q1 + 200,clrAqua);  
   ELLIPSE(q1 + 50,q1,q1 + q1*2,q1 * q1-30,clrBlack);  
   ELLIPSE(q1 + 52,q1,q1 + q1*3,q1 * q1-32,clrMagenta); 
   ELLIPSE(q1 + 54,q1,q1 + q1*4,q1 * q1-34,clrOrange); 
   FILLED_CIRCLE(q1 + 70,q1+20,20,clrDarkCyan);        
   FILLED_CIRCLE(q3,q2,40,clrGreen); 
   //------------------------------------
   REDRAW_CANVAS();
  }
 
Реter Konow:

By the way, check out what a step forward I've made thanks to our solutions yesterday (and your help):

In this particular example, everything is transferred through a resource.

Yes, it looks spectacular.

 
Реter Konow:

From all sides, it appears that the string is a universal medium for transmitting and receiving information.

I don't agree with you here. The universal workhorse for transferring information is the byte array.

I agree that text should be transferred as well. And I also agree that it's better to pass text as a string. But, in fact, a string is just an abstraction. When you passed texts via objects in the graph, the length of this text was limited to 64 characters. This means that behind the scenes you were actually passing an array of 64 bytes (MQL did all the work of converting a string into an array and back for you, not explicitly). If you're doing a project where exchange of information between MQL programs is a critical and fundamental point of the project, it's out of the question to leave this function to a generalized solution. If I were you, I would develop a generalized transfer system for arbitrary types, including strings, with strict conversion control. This could be done on the basis of parsing and reading resources. But on string parsing this is problematic, because there is no guarantee that the parsed string will be valid.

Reason: