DelphiBasics
StringOfChar
Function
Creates a string with one character repeated many times System unit
 function StringOfChar(RepeatCharacter Char; RepeatCount Integer):string;
Description
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
ConcatConcatenates one or more strings into one string
CopyCreate a copy of part of a string or an array
DeleteDelete a section of characters from a string
DupeStringCreates a string containing copies of a substring
InsertInsert a string into another string
MoveCopy bytes of data from a source to a destination
SetStringCopies characters from a buffer into a string
StringReplaceReplace one or more substrings found within a string
StuffStringReplaces a part of one string with another
WrapTextAdd line feeds into a string to simulate word wrap
 Download this web site as a Windows program.




 
Example code : Display a heading with underline characters beneath
var
  text, line : string;

begin
  // 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
  ShowMessage(text);
  ShowMessage(line);
end;
Show full unit code
  1.An introduction to life as we know it
  ---------------------------------------
  
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page