Download MetaTrader 5
To add comments, please log in or register
You don't know MQL5 but you do know how to sell? The affiliate program is at your service!
Keith Watford
Moderator
7862
Keith Watford 2015.03.13 22:08 

Hi,

I just don't get the explanation or the example in the documentation. 

If I have 

string txt= "Profit="+DoubleToStr(prof,2); 

for when profit=10 and 1000, output will be

Profit=10.00

Profit=1000.00 

but if I want it to output the DoubleTo Str with always a minimum of 8 characters

Profit=    10.00

Profit= 1000.00  

How do I do it.

Many thanks 

whroeder1
13592
whroeder1 2015.03.14 01:12  
GumRai but if I want it to output minimum of 8 charactersProfit=    10.00How do I do it.\
Change it to do what you want
string   RJust(string s, int size, string fill=" "){
   for(int n=size-StringLen(s); n > 0; n--)  s = fill+s;    return(s);        }
string   LJust(string s, int size, string fill=" "){
   for(int n=size-StringLen(s); n > 0; n--)  s = s+fill;    return(s);        }

string txt= "Profit="+RJust( DoubleToStr(prof,2), 8); 
or use StringFormat
   double d=54.21;
   PrintFormat("Profit='%8.2f'", d); // "Profit='   54.21'"
//                                               876

Keith Watford
Moderator
7862
Keith Watford 2015.03.17 07:06  
Thank you William.
/
To add comments, please log in or register