Download MetaTrader 5

PrintFormat() width, asterisk(*)

To add comments, please log in or register
honest_knave
Moderator
2373
honest_knave  

When specifying width, the documentation states that an integer value can be passed as a parameter: 

If an asterisk (*) is specified as width, value of int type must be indicated in the corresponding place of the list of passed parameters. It will be used for specifying width of the output value.

However, I'm unable to achieve this. Is this a bug or am I using incorrect syntax?

   printf("%s","mytext");
   printf("%10s","mytext");
   int width=10;
   printf("%*s",width,"mytext");

 

whroeder1
15321
whroeder1  
Try string, width?
Alain Verleyen
Moderator
32012
Alain Verleyen  
honest_knave:

When specifying width, the documentation states that an integer value can be passed as a parameter: 

If an asterisk (*) is specified as width, value ofint type must be indicated in the corresponding place of the list of passedparameters. It will be used for specifying width of the output value.

However, I'm unable to achieve this. Is this a bug or am I using incorrect syntax?

 

 

Seems like a bug, you can report it to ServiceDesk.
honest_knave
Moderator
2373
honest_knave  
WHRoeder:
Try string, width?
Thanks for the suggestion, but still doesn't work.
honest_knave
Moderator
2373
honest_knave  
angevoyageur:
Seems like a bug, you can report it to ServiceDesk.
OK, thank you.
honest_knave
Moderator
2373
honest_knave  

ServiceDesk has provided a workaround which doesn't use the asterisk:

   printf("%s","mytext");
   printf("%10s","mytext");
   int width=10;
   printf("%*s",width,"mytext");
   printf("%"+string(width)+"s","mytext");

 

Alain Verleyen
Moderator
32012
Alain Verleyen  
honest_knave:

ServiceDesk has provided a workaround which doesn't use the asterisk:

 

lol
honest_knave
Moderator
2373
honest_knave  
Indeed!
To add comments, please log in or register