MQL4 - MQLInfoInteger(MQL_CODEPAGE) always returns 0

To add comments, please log in or register
BaronWawelski
29
BaronWawelski  

Hello,


I think it's too complicated for me to use properly MQLInfoInteger() - ot always return 0 for me.


For example: 
Print("MQLInfoInteger(MQL_CODEPAGE) on Init: ", MQLInfoInteger(MQL_CODEPAGE));
MQLSetInteger(MQL_CODEPAGE, 850);
Print("MQLInfoInteger(MQL_CODEPAGE) after codepage change: ", MQLInfoInteger(MQL_CODEPAGE));   




gives the following output:
MQLInfoInteger(MQL_CODEPAGE) on Init: 0
MQLInfoInteger(MQL_CODEPAGE) after codepage change: 0


Do you know what's wrong with the code??

using version 4.00 build 1090



thanks!!

Mehrdad Jeddi
21820
Mehrdad Jeddi  

Hi,

So please read this documentation for more info about Codepage constant it's explained as well.

https://docs.mql4.com/constants/io_constants/codepageusage

Regards!

Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Alain Verleyen
36033
Alain Verleyen  
BaronWawelski:

Hello,


I think it's too complicated for me to use properly MQLInfoInteger() - ot always return 0 for me.


For example: 
Print("MQLInfoInteger(MQL_CODEPAGE) on Init: ", MQLInfoInteger(MQL_CODEPAGE));
MQLSetInteger(MQL_CODEPAGE, 850);
Print("MQLInfoInteger(MQL_CODEPAGE) after codepage change: ", MQLInfoInteger(MQL_CODEPAGE));   




gives the following output:
MQLInfoInteger(MQL_CODEPAGE) on Init: 0
MQLInfoInteger(MQL_CODEPAGE) after codepage change: 0


Do you know what's wrong with the code??

using version 4.00 build 1090



thanks!!

MQLInfoInteger(MQL_CODEPAGE) gives you the codepage used by the terminal. You can't change by code, so it returns always the same value.

When you are using MQLSetInteger() it changes the codepage of your running code.

Why are you trying to change it ?

BaronWawelski
29
BaronWawelski  

thanks. I have an issue with EA and Symbol(), _symbol and when running it on two different computers /win10 with different OS languages. Broker offers instruments with pound sign £. When I attach EA on chart, then no problem to OpenOrders but only if EA was compiled on the same machine. If I copy ex4 file to another machine I get 'unknown symbol' errror on order openning attempt beacuse of this pound sign. I don't want to compile twice (on 2 machines) so I thought I could use dynamic parameter and select code page that EA uses.



when run chcp command in windows I get the following response on 2 machines:
Active code page: 852

Active code page: 850



https://docs.mql4.com/constants/io_constants/codepageusage says that

CP_ACP

0

The current Windows ANSI code page.


When function MQLInfoInteger(MQL_CODEPAGE)will return any different code page than current windows code page?

Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Use of a Codepage - Input/Output Constants - Standard Constants, Enumerations and Structures - MQL4 Reference
Stanislav Korotky
24522
Stanislav Korotky  
Alain Verleyen:

MQLInfoInteger(MQL_CODEPAGE) gives you the codepage used by the terminal. You can't change by code, so it returns always the same value.

When you are using MQLSetInteger() it changes the codepage your the running code.

Why are you trying to change it ?

No, this is a property of specific MQL program, it can be changed according to the docs. Reasons for changing the codepage are explained.

MQLSetInteger - Checkup - MQL4 Reference
MQLSetInteger - Checkup - MQL4 Reference
  • docs.mql4.com
The MQLSetInteger() function is intended to change current codepage in a running MQL4 program. This can be useful when the client terminal sets the default codepage that is different from the one used when the program was compiled. For example, an MQL4 program was compiled on a computer with Spanish locale, while it is running on a machine with...
Alain Verleyen
36033
Alain Verleyen  
Stanislav Korotky:

No, this is a property of specific MQL program, it can be changed according to the docs. Reasons for changing the codepage are explained.

So ? I didn't say otherwise.

Even if you change it MQLInfoInteger(MQL_CODEPAGE) always returns the default codepage, it's all what I said.

Alain Verleyen
36033
Alain Verleyen  
BaronWawelski:

thanks. I have an issue with EA and Symbol(), _symbol and when running it on two different computers /win10 with different OS languages. Broker offers instruments with pound sign £. When I attach EA on chart, then no problem to OpenOrders but only if EA was compiled on the same machine. If I copy ex4 file to another machine I get 'unknown symbol' errror on order openning attempt beacuse of this pound sign. I don't want to compile twice (on 2 machines) so I thought I could use dynamic parameter and select code page that EA uses.



when run chcp command in windows I get the following response on 2 machines:
Active code page: 852

Active code page: 850



https://docs.mql4.com/constants/io_constants/codepageusage says that

CP_ACP

0

The current Windows ANSI code page.


When function MQLInfoInteger(MQL_CODEPAGE)will return any different code page than current windows code page?

Try 1250. (850/852 are related to DOS, certainly not the good ones).
Stanislav Korotky
24522
Stanislav Korotky  
Alain Verleyen:

So ? I didn't say otherwise.

Even if you change it MQLInfoInteger(MQL_CODEPAGE) always returns the default codepage, it's all what I said.

You said:

MQLInfoInteger(MQL_CODEPAGE) gives you the codepage used by the terminalYou can't change by code...

This is incorrect.

Alain Verleyen
36033
Alain Verleyen  
Stanislav Korotky:

You said:

This is incorrect.

This is not incorrect, your understanding of what I wrote is incorrect. That's means you can't change the codepage of Windows/Terminal, it's a deduction from the fact that MQLInfoInteger(MQL_CODEPAGE) always returns the same value even after you change it with MQLSetInteger(). Sorry if my formulation was not clear enough, but that doesn't really matter.

Do you have something useful to say to help the OP ?

Stanislav Korotky
24522
Stanislav Korotky  
Alain Verleyen:

This is not incorrect, your understanding of what I wrote is incorrect. That's means you can't change the codepage of Windows/Terminal, it's a deduction from the fact that MQLInfoInteger(MQL_CODEPAGE) always returns the same value even after you change it with MQLSetInteger(). Sorry if my formulation was not clear enough, but that doesn't really matter.

Do you have something useful to say to help the OP ?

I mean, OP did all correctly according to the documentation. If it does not work, then it's either the error in the documentation (and your deduction is correct), or there is a bug in the terminal, or terminal "thinks" both 850 and 852 are equal to default page, which results in 0 (and somewhat relates to the previous variant). I'm agree that 850/852 are not appropriate in Windows, and 1252 would be a better candidat, not 1250, as you suggested.

Apart from this we need more info from OP: exact windows versions and locale. Probably a short test code to play with.

Alain Verleyen
36033
Alain Verleyen  
Stanislav Korotky:

I mean, OP did all correctly according to the documentation. If it does not work, then it's either the error in the documentation (and your deduction is correct), or there is a bug in the terminal, or terminal "thinks" both 850 and 852 are equal to default page, which results in 0 (and somewhat relates to the previous variant). I'm agree that 850/852 are not appropriate in Windows, and 1252 would be a better candidat, not 1250, as you suggested.

Apart from this we need more info from OP: exact windows versions and locale. Probably a short test code to play with.

Thanks. About the right code to use, it depends on which computer it compiles, my guess is 1250 if computer 1, 1252 if computer 2. Let see his next post ;-)
12
To add comments, please log in or register