Реter Konow: Here's what I was thinking. There is a way to use resources from other programs. I guess the solution is there. I'll have to look in the documentation.
Incorrectly connected the resource.
You need to specify the path to the programme whose resource we want to read.
In the Inite of the reading programme, you must set the connection to the resource file in another programme:
if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"\\Experts\\Tester EA.ex4::Resource"))Print("Resource is not connected!");
And when reading the resource, also specify the full path:
if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",Data,width,height))Print("Failed to read resource! ",GetLastError());
//--------------------------------------------
But, there is a new nonsense:
When reading the resource, speckles appear in the line. Here is the code:
And the weird thing is that if we remove the Expert Advisor with the resource from the chart, the reading program will continue to receive the resource. This resource will have the same red text and rubbish. The rubbish is always different.
Interestingly, the size of the line of cursive characters is the same as the size of the array with the message.
But, in the stream of fringes there are sometimes flashes of almost exact Bid values that are written on the second side. They flicker once, and there are one or two fringes inside them too. But they are readable. And then, again, a stream of speckles.
It turns out that on the sender side of the resource fill event, everything is done correctly. Then, the reading side accepts the resource, which has been corrupted internally and littered. The faster the reading party reads the message in the resource, the more intact the message will be.
So you need accurate read/write synchronisation?
ZS. Dear fxsaber can you clarify what is wrong here?
ZS. Dear fxsaber, can you explain what is wrong here?
Many people here immediately see your mistakes, but prefer to keep silent as it is fraught with danger. And I understand them very well. I'd say in advance that I won't be answering afterwards. Learn to look for your own mistakes and properly build the attitude of others.
To the code.
You copy uint into uchar through ArrayCopy - an error.
Many people here see your mistakes straight away, but prefer to keep quiet as it is fraught with danger. And I understand them very well. I will not answer afterwards. Learn to look for your own mistakes and properly build the attitude of others.
To the code.
You copy uint into uchar through ArrayCopy - an error.
CharArrayToString - this will work if strings are ANSI.
Try to understand peculiarities of byte representation of types.
When people around me respect my solutions, I respect theirs. Well, you can't do it any other way. Mutual respect.
Shit, I'm sick of it. Took me half a day to figure it out.
Already figured out the unions. But this solution is a crutch in a cube. You still need byte operations there. But for my tasks, it is completely irrelevant.
It's much easier to work with object descriptions. It is guaranteed and simple. But I don't know if resources will work through the tester. It's not worth the trouble.
Here is a solution via unions:
//+------------------------------------------------------------------+//| Tester EA.mq4 |//| Peter Konow |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Peter Konow"#property link"https://www.mql5.com"#property version"1.00"#property strict//+------------------------------------------------------------------+union Char_Uint
{
uchar Char[8];
uint Uint[2];
double Double;
};
//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
//----------------------------------------------if(!ObjectCreate(0,"Resource",OBJ_BITMAP_LABEL,0,0,0))Print("Object is not created! ",GetLastError());
elsePrint("Object created!");
//-------------------------------if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"::Resource"))Print("BMPFILE is not created!");
elsePrint("BMPFILE created!");
//----------------------------------------------return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
//--- destroy timer
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
//---------------------------
Char_Uint u;
//---------------------------
u.Double = Bid;
//---------------------------if(!ResourceCreate("::Resource",u.Uint,2,1,0,0,0,COLOR_FORMAT_XRGB_NOALPHA))Print("Resource is not created!");
//---------------------------
}
//+------------------------------------------------------------------+//| Timer function |//+------------------------------------------------------------------+voidOnTimer()
{
//---
}
//+------------------------------------------------------------------+
And a reading indicator:
//+------------------------------------------------------------------+//| Resource reader.mq4 |//| Peter Konow |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Peter Konow"#property link"https://www.mql5.com"#property version"1.00"#property strict#property indicator_chart_window//+------------------------------------------------------------------+union Char_Uint
{
uchar Char[8];
uint Uint[2];
};
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingEventSetMillisecondTimer(5250);
if(!ObjectSetString(0,"Resource",OBJPROP_BMPFILE,"\\Experts\\Tester EA.ex4::Resource"))Print("Resource is not connected!");
elsePrint("Resource connected!");
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+//| Timer function |//+------------------------------------------------------------------+voidOnTimer()
{
//---
Char_Uint u;
uint width,height;
string Message;
//-----------------------------if(!ResourceReadImage("\\Experts\\Tester EA.ex4::Resource",u.Uint,width,height))Print("Failed to read resource! ",GetLastError());
//-----------------------------
Message = CharArrayToString(u.Char);
//-----------------------------Print(Message);
//-----------------------------
}
//+------------------------------------------------------------------+
I keep getting crocodiles. It's always different. So there's all sorts of rubbish in the resource. If its content was the same, then it wouldn't change too much.
In general, it's not clear how all this should work...
Unions are certainly an interesting thing. However, it doesn't occur to me for what purposes (other than conservation in a resource) it might be useful.
Beautiful monologue)
Hamlet rests.)
So, what's wrong?
the error -
ERR_RESOURCE_NOT_FOUND
https://www.mql5.com/ru/docs/runtime/resources
Read the help .
Quote:
https://www.mql5.com/ru/docs/runtime/resources
Read the reference .
Quote:
Yeah. Figured it out. I was plugging it in wrong.
Here's what I was thinking. There is a way to use resources from other programs. I guess the solution is there. I'll have to look in the documentation.
Incorrectly connected the resource.
You need to specify the path to the programme whose resource we want to read.
In the Inite of the reading programme, you must set the connection to the resource file in another programme:
And when reading the resource, also specify the full path:
//--------------------------------------------
But, there is a new nonsense:
When reading the resource, speckles appear in the line. Here is the code:
And the weird thing is that if we remove the Expert Advisor with the resource from the chart, the reading program will continue to receive the resource. This resource will have the same red text and rubbish. The rubbish is always different.
And how should you deal with it?
ZS. I'll try to specify other page encodings inCharArrayToString().
Interestingly, the size of the line of cursive characters is the same as the size of the array with the message.
But, in the stream of fringes there are sometimes flashes of almost exact Bid values that are written on the second side. They flicker once, and there are one or two fringes inside them too. But they are readable. And then, again, a stream of speckles.
It turns out that on the sender side of the resource fill event, everything is done correctly. Then, the reading side accepts the resource, which has been corrupted internally and littered. The faster the reading party reads the message in the resource, the more intact the message will be.
So you need accurate read/write synchronisation?
ZS. Dear fxsaber can you clarify what is wrong here?
I am attaching the files:
ZS. Dear fxsaber, can you explain what is wrong here?
Many people here immediately see your mistakes, but prefer to keep silent as it is fraught with danger. And I understand them very well. I'd say in advance that I won't be answering afterwards. Learn to look for your own mistakes and properly build the attitude of others.
To the code.
You copy uint into uchar through ArrayCopy - an error.
CharArrayToString - this will work if strings are ANSI.
Sort out peculiarities of byte representation of types.
Many people here see your mistakes straight away, but prefer to keep quiet as it is fraught with danger. And I understand them very well. I will not answer afterwards. Learn to look for your own mistakes and properly build the attitude of others.
To the code.
You copy uint into uchar through ArrayCopy - an error.
CharArrayToString - this will work if strings are ANSI.
Try to understand peculiarities of byte representation of types.
When people around me respect my solutions, I respect theirs. Well, you can't do it any other way. Mutual respect.
By the code. Thank you. I'll see what I can do.
Shit, I'm sick of it. Took me half a day to figure it out.
Already figured out the unions. But this solution is a crutch in a cube. You still need byte operations there. But for my tasks, it is completely irrelevant.
It's much easier to work with object descriptions. It is guaranteed and simple. But I don't know if resources will work through the tester. It's not worth the trouble.
Here is a solution via unions:
And a reading indicator:
I keep getting crocodiles. It's always different. So there's all sorts of rubbish in the resource. If its content was the same, then it wouldn't change too much.
In general, it's not clear how all this should work...
Maybe I'll find a solution later....
Unions are certainly an interesting thing. However, it doesn't occur to me for what purposes (other than conservation in a resource) it might be useful.