Does Java write the integer in a compatible byte order?
Have MT4 write the same file. Use a binary file editor to compare the java file and the MT4 file for byte ordering.
int start(){ int file = FileOpen("Test.bin", FILE_WRITE|FILE_BIN); FileWriteInteger(file, 400, LONG_VALUE); FileClose(file); file = FileOpen("Test.bin", FILE_READ|FILE_BIN); int value = FileReadInteger(file, LONG_VALUE); Print(" Value = ", value); // Output to terminal 2008.01.19 14:47:47 WriteTest EURJPY,M5: Value = 400 return(0); }
Dump of the binary file written by MT4...
File Address 00000000
4 hex bytes of data 90 01 00 00
$ dump "C:\Program Files (x86)\Metatrader\Metatrader\experts\files\Test.bin" C:\Program Files (x86)\Metatrader\Metatrader\experts\files\Test.bin: 00000000 9001 0000 ....
Java created file must be same bytes for it to be compatible
phy,
thank you very much!
Java writes the integer on inverse order. I have changed the Java code and it is working now:
thank you very much!
Java writes the integer on inverse order. I have changed the Java code and it is working now:
out.writeInt(Integer.reverseBytes(400));Thanks again and best regards!
Your flag is Brazil... I'm listening to Hermeto right now...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have to write a binary file in JAVA language and read it using MQL, but i am facing an incompatibility problem.
I am writing a simple integer ("400") value into a binary file ("data. dat") using the following Java code:
So i am trying to read this file using the following MQL code:
But the output is a number 83946924 !!!
How can i solve this problem??
Thanks & Regards,