STR() Function - Numeric to String Conversion and String Masking

Syntax

STR(num{:mask}{,ERR=lineref})
STR(string{:mask}{,ERR=lineref})

Description

For BBj-specific information, see STR() Function - BBj.

The first STR() function above returns an ASCII string representing the value of its numeric argument. The result can be formatted using the optional string mask. See Numeric Output for more information.

The NUM() function is complementary to the STR() function when the STR() function is used without a mask that places nonnumeric characters in the result.

In the second syntax example above, the STR() function returns its string argument applied to the specified mask. The specified positions in the mask are filled with successive characters from string. The following characters in mask are replaced by characters from string:

Mask Character

Accepts

X

Any printable character.

a

Any alphabetic character.

A

Any alphabetic character. Converts lower-case alphabetic characters to upper case.

0

Any digit.

z

Any digit or alphabetic character.

Z

Any digit or alphabetic character. Converts lower-case alphabetic characters to upper case.

Any other character in the mask represents itself. If a character type mismatch occurs, such as trying to place a "W" into a mask position designated for a digit, an error is generated. If the source string is too short, spaces are used to pad the remainder of the mask. If the source string is too long, an error is generated.

Examples

>PRINT STR(123:"0000")
0123
>PRINT STR(52.3)
52.3
>PRINT STR(3352.3:"$##,##0.00")
$3,352.30
>PRINT STR("abcdefg":"XX-XXX-XX")
ab-cde-fg

See Also

Functions - Alphabetical Listing



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.