$tocharacter

$tocharacter

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

$tocharacter

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

Syntax

$tocharacter(expression,length)

Parameters

expressionAny value, or an expression that yields any value.
lengthA 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.

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