SPACE
Synopsis
SPACE(count) {fn SPACE(count)}
Arguments
Argument | Description |
---|---|
count | An integer expression specifying the number of blank spaces to return. |
Description
SPACE returns a string of blank spaces count spaces long. If count is a numeric string, a decimal number, or a mixed numeric string, Caché resolves it to its integer portion. If count is a negative number or a nonnumeric string, Caché resolves it to 0.
To remove blank spaces from a string, use LTRIM (leading blanks) or RTRIM (trailing blanks).
The SPACE function should not be confused with the SPACE collation type. SPACE collation appends a single space to a value, forcing it to be evaluated as a string. To establish SPACE collation, CREATE TABLE provides a %SPACE collation keyword, and ObjectScript provides the Collation()Opens in a new tab method of the %SYSTEM.UtilOpens in a new tab class.
Examples
The following embedded SQL example returns a string of spaces the length of the name field:
&sql(SELECT SPACE(LENGTH(name))
INTO :a
FROM Sample.Person)
IF SQLCODE'=0 {
WRITE !,"Error code ",SQLCODE }
ELSE {
WRITE !,"Leave this much space:",a,"for names" }