JCL Help:StrCenter@AnsiString@SizeInt@AnsiChar

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Centers a string.


Pascal

 function StrCenter(const S: string; L: SizeInt; C: Char = ' '): string;
function StrCenter(const S: AnsiString; L: SizeInt; C: AnsiChar = ' '): AnsiString;


Parameters

Parameters Description
const S: string The string to center.
L: SizeInt The desired length of the resulting string.
C: Char = ' ' The character to use for padding.


Return Value

Returns the centered string.


Description

The StrCenter routine takes the specified string and pads it on both the left and right side with the specified character until the resulting string is of the specified length. While doing this the original string is kept centered. That is, there is the same amount of padding at the left side as there is on the right side. If the specified length is smaller than the length of the original the string remains unchanged. In cases where an odd number of padding chars have to be inserted there is always one more padding char on the right side than on the left side.


About

Unit

JclAnsiStrings


Donator

Alexander Radchenko


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page