I also want to puzzle you with something that puzzled me.))) Is it possible to pass several individual lines in one resource, so that you can read only the selected line from it while reading the resource.
For an image a few lines can be created through TextOut() but attempts to read such a resource has no success. Only the first line can be read.
I also want to puzzle you with something that puzzled me.))) Is there a possibility to pass some separate lines in one resource, so that it's possible to read only selected line from it.
For an image a few lines can be created through TextOut(), but attempts to read this resource have failed. Only the first line can be read.
There is no point in trying to save or read text from a picture. Use the resource to write strings as I described above, then extract back using CharArrayToString. Next, split the string by a delimiter and find the right one among them. (Hence, before saving the string, divide it into substrings by some symbol).
Реter Konow: There is no point in trying to save or read text from a picture. Use the resource to write strings as I described above and then extract back using CharArrayToString. Next, split the string by a delimiter and find the right one among them. (Hence, before saving the string, divide it into substrings by some symbol).
I had no desire to read from a picture. I only mentioned the picture as an example of an entry in a few lines.
Pulling out a substring is too easy. We are not looking for easy ways :))) Thanks for the help.
I had no desire to read from a picture. I only mentioned the picture as an example of a few lines of writing.
To take out a substring, it's too easy. We're not looking for easy ways.) Thanks for the help.
It's not too hard to pull a substring if you already know how to save data in a resource and extract it. This is a simple task in itself. Try saving the string to a resource first and then extracting it from there. Then add a function to break the string into substrings and search for the right one.
Реter Konow: It's not too hard to pull out a substring if you already know how to save data in a resource and retrieve it. It is a simple task in itself. Try saving the string to a resource first and then extracting it from there. Then add a function to break the string into substrings and search for the right one.
Peter thanks for your help. I learned how to work with strings years ago. And how to save a resource and read it, with your help, I figured it out yesterday. Just got a frantic text message in my head, like I should try it... and how to do it the text message got lost on the way, got lost in my thoughts.
I'm trying to figure out the difference between two-dimensional and one-dimensional arrays for creating resources. Do you have any developments, thoughts on this?
Peter thanks for your help. I learned how to work with strings years ago. And how to save a resource and read it, with your help, I figured it out yesterday. Just got a frantic text message in my head, like I should try it... but how to do it the text message got lost in the way, got lost in my thoughts.
So now I'm trying to figure out the difference between two-dimensional and one-dimensional arrays for creating resources. Do you have any insights, thoughts on this?
To be honest, I've never stored a two-dimensional array in a resource. I've always worked with a one-dimensional one, because it's unconstrained. One-dimensional is better for saving data, although it doesn't have to be. It depends on what kind of data and in what format. Use only a one-dimensional array for string saving, because the two-dimensional array cannot be sent to CharArrayToString and StringToCharArray functions. So, I'd advise you to develop a mechanism to store any of your data in a one-dimensional array for flexibility. But, you can try to use two-dimensional for non-string data of the same type. It will be interesting to see what you get out of it.
I read some earlier pages and realized that the task was to read only one small string from the resource. If this string is less than 64 characters, there's no sense in making a mess with unions and saving data to the resource. Just write the required string to description property of OBJPROP_TEXT:
// Пример хранения/обмена данными через Ресурсы внутри Терминала#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/ru/code/22166voidOnStart()
{
const RESOURCEDATA<int> ResourceINT("::int"); // Ресурс для обмена int-ами. const - как доказательство, что ничего не пишется в объект классаint ArrayINT[] = {1, 2, 3};
int Num = 5;
ResourceINT = ArrayINT; // Ресурс хранит массив.
ResourceINT += Num; // Добавили в ресурс еще значение.
ResourceINT += ArrayINT; // Добавили массив.int ArrayINT2[];
ResourceINT.Get(ArrayINT2); // Считали данные из ресурса.ArrayPrint(ArrayINT2); // Вывели: 1 2 3 5 1 2 3
ResourceINT.Free(); // Удалили данные из ресурсаPrint(ResourceINT.Get(ArrayINT2)); // Убедились, что данных нет: 0const RESOURCEDATA<MqlTick> ResourceTicks("::Ticks"); // Ресурс для обмена тиками. const - как доказательство, что ничего не пишется в объект классаMqlTick Tick;
if (SymbolInfoTick(_Symbol, Tick))
for (int i = 0; i < 3; i++)
ResourceTicks += Tick; // Добавили в ресурс тикиMqlTick Ticks[];
ResourceTicks.Get(Ticks); // Считали данные из ресурса.ArrayPrint(Ticks); // Вывели.// Это полное имя ресурса для обращения из другой программыconststring NameOut = StringSubstr(MQLInfoString(MQL_PROGRAM_PATH), StringLen(TerminalInfoString(TERMINAL_PATH)) + 5) + "::Ticks";
Print(NameOut); // Вывели полное имя ресурса.const RESOURCEDATA<MqlTick> Resource(NameOut); // Ресурс для доступа к данным (read-only) из другой программыMqlTick TicksOut[];
Resource.Get(TicksOut); // Считали данные из ресурса.ArrayPrint(TicksOut); // Вывели.
Resource.Free(); // Не получится повлиять на данные read-only-ресурса.Print(_LastError); // ERR_INVALID_PARAMETER - Ошибочный параметр при вызове системной функции.
}
I read some earlier pages and realized that the task was to read only one small string from the resource. If this string is less than 64 characters, there's no sense in making a mess with unions and saving data to the resource. Just write the required string to description property of OBJPROP_TEXT:
Not exactly. The task was to output a few lines of information. In my opinion... it's just the way I wanted it to be displayed. One of the lines has a date in it. This date is not only for clarity, but should be used by the program even after the restart. It turns out that it has to be saved somehow. This is where I started messing around, we're not looking for easy ways out. Since one way to save the date is to use a graphical object, why not use the same resource. After restarting MT resource is readable, but after restarting the computer has not checked yet. The main thing is that I figured out resources and units. The next thing I knew, I was getting frantic text messages in my head. Once I've deleted everything, I'll continue the useful work.
Not really. The task was to output a few lines of information. In my opinion ... that's just the way I wanted it to be, to display it with a canvas. One of the lines has a date in it. This date is not only for clarity, but it should be used by the program even after the restart. It turns out that it has to be saved somehow. This is where I started messing around, we're not looking for easy ways out. Since one way to save the date is to use a graphical object, why not use the same resource. After restarting MT resource is readable, but after restarting the computer has not checked yet. The main thing is that I figured out resources and units. The next thing I knew, I was getting frantic text messages in my head. Once I've deleted everything, I'll continue the useful work.
Good. Then keep mastering resources and unions. They offer a versatile way to not only write and store any data quickly, but also to share that data between different programs in real time and with no load on the disk.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Of course.
I also want to puzzle you with something that puzzled me.))) Is it possible to pass several individual lines in one resource, so that you can read only the selected line from it while reading the resource.
For an image a few lines can be created through TextOut() but attempts to read such a resource has no success. Only the first line can be read.
I also want to puzzle you with something that puzzled me.))) Is there a possibility to pass some separate lines in one resource, so that it's possible to read only selected line from it.
For an image a few lines can be created through TextOut(), but attempts to read this resource have failed. Only the first line can be read.
There is no point in trying to save or read text from a picture. Use the resource to write strings as I described above and then extract back using CharArrayToString. Next, split the string by a delimiter and find the right one among them. (Hence, before saving the string, divide it into substrings by some symbol).
I had no desire to read from a picture. I only mentioned the picture as an example of an entry in a few lines.
Pulling out a substring is too easy. We are not looking for easy ways :))) Thanks for the help.
I had no desire to read from a picture. I only mentioned the picture as an example of a few lines of writing.
To take out a substring, it's too easy. We're not looking for easy ways.) Thanks for the help.
It's not too hard to pull out a substring if you already know how to save data in a resource and retrieve it. It is a simple task in itself. Try saving the string to a resource first and then extracting it from there. Then add a function to break the string into substrings and search for the right one.
Peter thanks for your help. I learned how to work with strings years ago. And how to save a resource and read it, with your help, I figured it out yesterday. Just got a frantic text message in my head, like I should try it... and how to do it the text message got lost on the way, got lost in my thoughts.
I'm trying to figure out the difference between two-dimensional and one-dimensional arrays for creating resources. Do you have any developments, thoughts on this?
Peter thanks for your help. I learned how to work with strings years ago. And how to save a resource and read it, with your help, I figured it out yesterday. Just got a frantic text message in my head, like I should try it... but how to do it the text message got lost in the way, got lost in my thoughts.
So now I'm trying to figure out the difference between two-dimensional and one-dimensional arrays for creating resources. Do you have any insights, thoughts on this?
I read some earlier pages and realized that the task was to read only one small string from the resource. If this string is less than 64 characters, there's no sense in making a mess with unions and saving data to the resource. Just write the required string to description property of OBJPROP_TEXT:
ObjectSetString(chartID,label_name,OBJPROP_TEXT, "Your string");
And get it back like this:
string Str = ObjectGetString(chartID,label_name,OBJPROP_TEXT);
And that's it.))
Forum on trading, automated trading systems and testing trading strategies
Libraries: TradeTransactions
fxsaber, 2018.09.20 16:23
I read some earlier pages and realized that the task was to read only one small string from the resource. If this string is less than 64 characters, there's no sense in making a mess with unions and saving data to the resource. Just write the required string to description property of OBJPROP_TEXT:
ObjectSetString(chartID,label_name,OBJPROP_TEXT, "Your string");
And get it back like this:
string Str = ObjectGetString(chartID,label_name,OBJPROP_TEXT);
And that's it.))
Not exactly. The task was to output a few lines of information. In my opinion... it's just the way I wanted it to be displayed. One of the lines has a date in it. This date is not only for clarity, but should be used by the program even after the restart. It turns out that it has to be saved somehow. This is where I started messing around, we're not looking for easy ways out. Since one way to save the date is to use a graphical object, why not use the same resource. After restarting MT resource is readable, but after restarting the computer has not checked yet. The main thing is that I figured out resources and units. The next thing I knew, I was getting frantic text messages in my head. Once I've deleted everything, I'll continue the useful work.
Not really. The task was to output a few lines of information. In my opinion ... that's just the way I wanted it to be, to display it with a canvas. One of the lines has a date in it. This date is not only for clarity, but it should be used by the program even after the restart. It turns out that it has to be saved somehow. This is where I started messing around, we're not looking for easy ways out. Since one way to save the date is to use a graphical object, why not use the same resource. After restarting MT resource is readable, but after restarting the computer has not checked yet. The main thing is that I figured out resources and units. The next thing I knew, I was getting frantic text messages in my head. Once I've deleted everything, I'll continue the useful work.
Good. Then keep mastering resources and unions. They offer a versatile way to not only write and store any data quickly, but also to share that data between different programs in real time and with no load on the disk.