Discussing the article: "Studying PrintFormat() and applying ready-made examples" - page 2

 

Artem, please explain this as well:

//--- Write the value with digits equal to 2 и указываем, что свойство отображается в процентах
   PrintFormat("%*s%-*s%-.2 f %%",indent,"",w,header,AccountInfoDouble(ACCOUNT_MARGIN_LEVEL));

The margin width and the text "Margin level:" and what does it mean?

I've experimented, but I can't formulate an explanation.

 
Alexey Viktorov #:

Artem, explain this one more, please:

Marginwidth and the text "Margin level:", and what does it mean?

I've experimented, but I can't formulate an explanation.

Line margin from the left edge
 
Artyom Trishkin #:
Line indentation from the left edge

But why is there an empty line ""? Because an empty line has a length of 0. Then no matter how much empty line you put, it will still be empty. But if you put some text there, then this text will be displayed instead of indentation and there will be no indentation....

This is the first time I've seen insufficient information in documentation. This once again confirms the usefulness of your articles. Thank you.

 
Alexey Viktorov #:

But why is there an empty string ""? Because the empty string has a length of 0. Then no matter how much empty space you put in it, it will still be empty. But if you put some text there, then this text will be displayed instead of indentation and there will be no indentation....

This is the first time I've seen insufficient information in documentation. This once again confirms the usefulness of your articles. Thank you.

The space is in the format string. Read this series of articles from the beginning - I described this design there
 
Artyom Trishkin #:
The space is in the format string. Read this series of articles from the beginning - I described this construction there

Yes, I apologise. I only read up to

Formatted output of count properties

and then skipped a bit further....

This once again confirms the usefulness of your articles. Thank you.

 
Artyom Trishkin #:
Line indentation from the left edge

My experiments have shown that it is possible to indent before any field

 PrintFormat("%*sText_1%12sText_2", 5,"","");

/*
 Text_1 Text_2
*/
 
Alexey Viktorov #:

My experiments have shown that you can indent in front of any field

Naturally. The article shows it just as an addition to the reference materials using a simple example. Someone just reads/not reads it, and someone, having seen it, experiments and makes useful conclusions for himself ;)

HI. Now you know how to make any indentation/space size specified by a variable in any place of a text string

 

This is how you can specify the number of spaces:

   PrintFormat("%*sText_1%*sText_2", 5,"",12,"");

/*
 Text_1 Text_2
*/

In general, where numbers are used in a format string to specify the digit capacity of something, you can substitute an asterisk and then specify the required value in the parameters. If you use it in your function, then in the formal parameters pass the required value to form a string with the required digit capacity/accuracy/number of characters

 
Artyom Trishkin formal parameters pass the required value to form a string with the required digit/accuracy/number of characters

I did it differently on purpose, with an asterisk * and directly in the format string.

I also experimented with saving the format string to a variable of string type and inserting it - it works. That is, if you need to output the same type of strings several times, you can use a variable containing the format string, so you don't have to type it several times and write a separate function.

 
Alexey Viktorov #:

I purposely did it differently, with an asterisk * and directly in the format string.

I also experimented with saving the format string into a variable of string type and pasting it - it works. That is, if you need to output the same type of strings several times, you can use a variable containing the format string, so you don't have to type it several times and write a separate function.

I would like to attach an example...)