$center

$center

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

$center

$center

or $centre

Centers a non-blank character string.

Syntax

$center|$centre(string)

Parameters

stringa 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.)

See Also

$leftjustify

$length

$rightjustify

About Character Literals

About Data Types

About Functional Expressions

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Leave a Reply

Your email address will not be published. Required fields are marked *

en_CAEnglish