# str

### str(source, [length, decimals, padChar])

Convert a number to a string, with optional length, number of decimal places, and padding character.

## Arguments

Argument | Data Type | Description
source | number | Number to be converted
length | number | How long the final string is to be
decimals | number | How many positions after the decimal point (default none)
padChar | string | Character to put at the front of the string to pad it out to the required length. Default is space.

## Returns

A string in the required format

## Description

Converts a number to a string. The string will always be in the format "123456", or "12346.78" if decimal places are specified. The pad char allows you to specify a leading character (default is space)

The str() function also converts a number to a string, but is restricted in the formats it can produce.

## Examples

The examples all show a number as the source for clarity - you can of course use a Field ID to get the contents of a field instead.

Example | Returns | Description
str(123) | "123" | Simplest possible format - just gives you the number
str(123, 4) | " 123" | Adds spaces at the front to pad the string
str(123, 6, 1) | " 123.0" | Can specify decimal points
str(123, 8, 1, "x") | "xxx123.0" | Specify a different leading pad character

## See Also

ston(), ston(), val(), Number Formatting