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

 
Реter Konow:
In short, every time you change a user parameter value, this value should be converted to a variable value from the union and immediately saved to a shared byte array, which you can then convert to uint and write to the resource.

You must have a user parameter inside the union structure. When you change the parameter, the structure will change with a simultaneous change of the int array

union c
{
  uint i[2];
  long width;
}cc;
 
cс.width = 200;

i[2] is a user resource that is read by another program.

With one line cc.width = 200 you will change:

  1. The parameter responsible for the width,
  2. The structure containing this parameter,
  3. The array of the resource being read by the other program.

And there is no conversion and copying here, just mapping.
 
Vasiliy Sokolov:


I can change the wrapper functions in the Connection Properties file and convert each usable value to the corresponding variable from the union, and make a byte array on the fly. But, text values which also need to be passed, converted to byte array usingStringToChar().

However, this removes the point of using a union. After all, if I have to useStringToChar() anyway, why not assemble everything into a string and then translate the whole string into bytes usingStringToChar()?

 
Vasiliy Sokolov:

You must have a user parameter inside the union structure. When you change the parameter, the structure will change with a simultaneous change of the int array

i[2] is a user resource that is read by another program.

With one line cc.width = 200 you will change:

  1. The parameter responsible for the width,
  2. The structure containing this parameter,
  3. The array of the resource which is read by a third-party program.

And there's no conversion or copying here, just mapping.

Vasily, you're forgetting that we're talking about two-way communication. In my engine, I can tie everything to unions, but I can't be responsible for the user code. I can only come up with wrappers and put them in the plugins.

Where's the guarantee that the user will also use unions? So when he calls my wrapper functions, I have to take his value myself and cast to one of my variables from my unions inside his plugin file.

 
Реter Konow:

I can change the wrapper functions in the Connection Properties file and convert each usable value to the corresponding variable from the union, and make a byte array on the fly. However, text values, which must also be passed, must be converted to a byte array usingStringToChar().

However, this removes the point of using a union. After all, if I have to useStringToChar() anyway, why not assemble everything into a string and then translate the whole string into bytes usingStringToChar()?

Because you'll have double parsing. You'll convert everything to a string, which is very slow. Then you parse the string into an array, which is very fast. Then you assemble it back to a string - that's very fast. Then you parse the string into the right types - that's very slow.

 
Реter Konow:

OK, but what about texts?

They have to be converted into bytes viaStringToChar(). You can't use union, right?

Yes, you have to translate them, but it's fast, unlike parsing.

 

For example:

Here is the wrapper function in theConnection Properties plug-in file:

string E_Last_10_bars_2_Close_price(string n = rare_value,  int Property = -1){return(GET_N_SET(11,n,Property));}

This function is called like this:

E_Last_10_bars_2_Close_price(Close[2]);

That is, the user sets the value ofClose[2] in a table cell.

Close[2] - это значение дабл.

Hence, inside his wrapper function in his program, I can represent the value(Close[2]) as a char array.

But, in the same cell, the user can send the value "Hello! :)", and then what to do?

E_Last_10_bars_2_Close_price("Привет! :)");
 
 

Oh, Peter, you started with the wrong programming language. You should have learned something not strictly typed.

In general, I understood you, you invented your own untyped language based on MQL. You got around its strict typing by using strings. This is a maneuver!

 
Vasiliy Sokolov:

Oh, Peter, you started with the wrong programming language. You should have learned something not strictly typed.

In general, I understood you, you invented your own untyped language based on MQL. You got around its strict typing by using strings. This is a maneuver!

Yeah,)) A move with a knight!

 

If you are using a table, you must decide whether you want the data in the table to be strictly numeric or textual. If text, you pass in strings. If it is real, your function must look like this:

string E_Last_10_bars_2_Close_price(double n,  int Property = -1){return(GET_N_SET(11,n,Property));}
Reason: