Compatible Unicode Intrinsic Functions - Centre Method

Centre the string within the variable

Member of Compatible Unicode Intrinsic Functions (PRIM_LIBI.ICompatibleUnicodeIntrinsics)

Parameters

NameTypeData TypeDescription
Result*Result (Optional)Unicode StringResulting centred string
Length*Input (Optional)IntegerLength of the variable to centre within
Pad*Input (Optional)Unicode StringPadding character used when the string doesn't fill the variable

Details

Center allows a string to be centered within a given length, and will optionally pad the result with a supplied character. Leading and trailing spaces are significant and will be evaluated as part of the string to center.
 
If the string is longer than the target variable, the first n bytes of the string are used. Where the result of centering the string results is an uneven number of bytes, the extra byte will be allocated to the right-hand side.
 
Typically, centering is used to center a value within a target variable. By using the Length parameter you can control how the string is centered and padded.
 
Center can only be used to center a string within a target string. This does not guarantee that the result will be visually centered if the font being used in non-proportional.

Example

In this example, if #String is a 40 byte variable that contains a value of ?Centered Text?, the result is ?***Centered Text****?. The remaining 20 bytes of #string will be null
#Target := #string.Center(20 ?*?)
In this example, where string is a 20 byte variable that contains a value of ?Centered Text?, the result would be ?  Centered Text  ?.  This is a typical centering scenario where the length of the target governs the centering of the text:
#Target := #string.Center( #Target.FieldLength)

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2