Download MetaTrader 5
To add comments, please log in or register
Do you want to write a trading robot? Find solution in MQL5 Reference!
Marcos Silva
305
Marcos Silva 2015.07.20 15:24 

Im looking to print the following

value :3  as 00003

value :124 as 00124

value :8324 as 08324

in this case it would be 5 characters.. 

is it possible?

Thanks             
 

Carl Schreiber
5954
Carl Schreiber 2015.07.20 16:28  
Look in the reference for PrintFormat() of StringFormat().
JD4
1101
JD4 2015.07.20 16:32  

Do you mean you want decimals as in your value 3 is actually .00003, or you want 3 with leading zeros that would normally not be there?

It makes a difference.  But, if you want to output stuff, you need to convert your data to a string in some way.

Here are some doc links to get you started.

Conversion Functions

String Functions

Common Functions

whroeder1
13627
whroeder1 2015.07.20 17:52  
PrintFormat("%05d", 3); // 00003
Marcos Silva
305
Marcos Silva 2015.07.20 18:26  

Got it suiting my needs using:

 int number = 3;

 string NumbWith6Digits =  IntegerToString(number,6,'0'); 

Marcos Silva
305
Marcos Silva 2015.07.20 18:27  
Thank You guys!
/
To add comments, please log in or register