Creates a string with one character repeated many times System unit
 function StringOfChar ( RepeatCharacter : Char; RepeatCount : Integer ) : string;
The StringOfChar function creates a new string of length RepeatCount, filled by RepeatCharacter characters.
This function avoids the need for a for loop, or tedious typing.
Related commands
Concat Concatenates one or more strings into one string
Copy Create a copy of part of a string or an array
Delete Delete a section of characters from a string
DupeString Creates a string containing copies of a substring
Insert Insert a string into another string
Move Copy bytes of data from a source to a destination
SetString Copies characters from a buffer into a string
StringReplace Replace one or more substrings found within a string
StuffString Replaces a part of one string with another
WrapText Add line feeds into a string to simulate word wrap
 Author links

 Download this web site as a Windows program.

Example code : Display a heading with underline characters beneath
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
unit Unit1;
  // The System unit does not need to be defined
  Forms, Dialogs;
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
Form1: TForm1;
{$R *.dfm} // Include form definitions
procedure TForm1.FormCreate(Sender: TObject);

  text, line : string;

  // Write a heading with -'s as underline characters
  text := '1.An introduction to life as we know it';
  line := StringOfChar('-', Length(text));

  // Display our underlined heading
Hide full unit code
   1.An introduction to life as we know it
Delphi Programming Neil Moffatt 2002 - 2020. All rights reserved.  |  Home Page