Questions from Beginners MQL5 MT5 MetaTrader 5 - page 458

 

Can you tell me how to make numbers out of text?

There is a text string="OpenOrder_Part=1";

I need to separate the digit 1 and convert it to "int".

 
-Aleks-:

Can you tell me how to make numbers out of text?

There is a text string="OpenOrder_Part=1";

I need to separate the digit 1 and convert it to "int".

Look for signs after "=" and StringToInteger()
 
-Aleks-:

Can you tell me how to make numbers out of text?

There is a text string="OpenOrder_Part=1";

I need to separate the digit 1 and convert it to "int".

At a glance - split the string by the "=" delimiter. The StringSplit() function. And then StringToInteger().
 
Artyom Trishkin:
Look for signs after "=" and StringToInteger()

Thank you.

Strangely, StringToInteger() was not needed - numbers add up without this function.


Tapochun:
At a glance, to split a string with "=" delimiter. The StringSplit() function. And then StringToInteger().

Thank you! It worked fine, but now I can't code the string correctly - combine text with digits. And it's not clear what to do if I don't know where the digit is...

I write like this

int CountPendingOrder_OS=1;

string comm="CountPendingOrder_OS_"+CountPendingOrder_OS;

what is wrong?
 
-Aleks-:

Thank you.

Strangely, StringToInteger() wasn't needed - the numbers add up without that function.


Thank you! It worked fine, but now I can't code the string correctly - combine the text with the numbers. And it's not clear how to do it, if I don't know where the digit is...

I write it like this

int CountPendingOrder_OS=1;

string comm="CountPendingOrder_OS_"+CountPendingOrder_OS;

What's wrong?

This is why I needed StringToInteger(). But it could be simpler.

string comm = ""+(string)CountPendingOrder_OS.

You are trying to connect the string part to the integer part. That's why there is an error. You should convert the integer part into the string one. In this case you need to use explicit conversion.

 
Tapochun:

That's why the StringToInteger() function was needed. But it could be simpler.

string comm = ""+(string)CountPendingOrder_OS.

You are trying to connect the string part to the integer part. That's why there is an error. You should convert the integer part into the string one. In this case you need to use explicit conversion.

Thanks, but it's frustrating that IntegerToString() can't handle numeric zero - it replaces it with "placeholder"!
 
-Aleks-:
Thanks, but it's frustrating that IntegerToString() can't handle numeric zero - it replaces it with a "placeholder"!
Then use explicit conversion.
 
Tapochun:
Then use explicit conversion.

How's that? :) I've done a zero check so far...


I also caught an error, but I don't know how to interpret it...

2015.10.15 14:54:46.709 2011.06.29 10:50 Testing pass stopped due to a critical error in the EA

2015.10.15 14:54:46.709 2011.06.29 10:50 Access violation read to 0x00000006 in 'C:\Users\<...>\Kamikadze_MA-9.ex4'

 
-Aleks-:

...

I also caught an error, but I don't know how to interpret it...

2015.10.15 14:54:46.709 2011.06.29 10:50 Testing pass stopped due to a critical error in the EA

2015.10.15 14:54:46.709 2011.06.29 10:50 Access violation read to 0x00000006 in 'C:\Users\<...>\Kamikadze_MA-9.ex4'

With this error in servicedesk.
 
-Aleks-:

How's that? :) I've done a zero check so far...


I also caught an error, but I don't know how to interpret it...

2015.10.15 14:54:46.709 2011.06.29 10:50 Testing pass stopped due to a critical error in the EA

2015.10.15 14:54:46.709 2011.06.29 10:50 Access violation read to 0x00000006 in 'C:\Users\<...>\Kamikadze_MA-9.ex4'

I described it above: (string) before variable name.

MT5?

Reason: