Files
mql5-skills/skills/mql5/references/docs/09-strings/0632-strings-stringfill.md
T
2026-06-23 21:47:51 +08:00

52 lines
1.3 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# StringFill
It fills out a selected string by specified symbols.
```
bool  StringFill(
   string&   string_var,       // string to fill
   ushort    character         // symbol that will fill the string
   );
```
Parameters
string_var
[in][out]  String, that will be filled out by the selected symbol.
character
[in]  Symbol, by which the string will be filled out.
Return Value
In case of success returns true, otherwise - false. To get the [error code](/en/docs/constants/errorswarnings/errorcodes) call [GetLastError()](/en/docs/check/getlasterror).
Note
Filling out a string at place means that symbols are inserted directly to the string without transitional operations of new string creation or copying. This allows to save the operation time.
Example:
```
void OnStart()
  {
   string str;
   StringInit(str,20,'_');
   Print("str = ",str);
   StringFill(str,0);
   Print("str = ",str,": StringBufferLen(str) = ", StringBufferLen(str));
  }
// Result
//   str = ____________________
//   str =  : StringBufferLen(str) = 20
//
```
See also
[StringBufferLen](/en/docs/strings/stringbufferlen), [StringLen](/en/docs/strings/stringlen), [StringInit](/en/docs/strings/stringinit)