$center

or $centre

Centers a non-blank character string.

Syntax

$center|$centre(string)

Parameters

string

a character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of string centered in a space $length(string) characters long. Leading or trailing blanks in string are ignored during centering. If string contains an odd number of characters, it centers with a bias to the left.

Comments

String is centered in an area that is $length(string) characters long. All leading and trailing blanks in string are ignored. If string contains an odd number of characters, the string is centered with a bias to the left.

Example

$center("abcde ")

Evaluates to " abcde ". Centering five characters in a 10-character field produces a string that contains two spaces on the left and three spaces on the right.

$center(var3)

Evaluates to " 3 ". If var3 is an INT variable whose value is 3, the resulting value is a string of eight characters, with three spaces to the left of the 3 and four spaces to the right. (INT values occupy eight character spaces when converted to character strings.)

 

Related Topics