$tocharacter

Converts an expression to the character data type and sets the length of the result.

Syntax

$tocharacter(expression,length)

Parameters

expression

Any value, or an expression that yields any value.

length

A number that specifies the number of characters in the resulting character string. Length can be a constant, a variable, a form field, or a parameter.

Return Value

Character (char), length bytes long.

Comments

Use $tocharacter to convert expression to the CHAR data type in an area length bytes long. If length is negative, the result string is set to the maximum possible length.

String comparisons involving this function are case-sensitive.

If expression is a number, the number is converted to character string form in an area length bytes long. If the given area is not large enough to hold the converted value, an error results.

Example

Assume LastName is "Smith ".

$tocharacter(LastName,3)

Evaluates to "Smi".

$tocharacter(LastName,12)

Evaluates to "Smith ".

$tocharacter(50,2)

Evaluates to "50".

$tocharacter(200+300,20)

Evaluates to " 500" (17 leading spaces).

$tocharacter(500,-2)

Evaluates to " 500" (14 leading spaces).

list all Emps \

  format $tocharacter(FirstName,6), $tocharacter(LastName,9)

$tocharacter changes the width of values being output with a LIST command.

 

Related Topics