Skip to main content

asString

Converts a non-string value to a string.

This function is useful if you want to treat a non-string value as a string, thereby allowing you to input the value to another function. For example, the len function, which counts the number of characters in a string, can return the number of digits in a number if you perform a number-to-string conversion beforehand.

When the function converts a number to a string, the returned string is identical to how the number would be formatted in your project output. This means you must remain mindful of your Number and Currency settings. See the examples below for further guidance.

Parameters

  • X (any)

    The value that you want to convert.

Examples

Assume the settings in Settings > Number and Currency are:

Setting

Value

LOCALE

en_US

NUMBER FORMAT

#,##0.##

The settings ensure that numbers are displayed to a maximum of two decimal places with trailing zeros stripped. They also ensure that commas are used for thousand separators and a period is used for the decimal point.

ATL in Script

Result

Notes

[[asString(100000)]]

100,000

The input number would be displayed as 100,000 in the project output, so the returned string shows the same.

[[len(asString(100000))]]

7

The produced string (100,000) contains six digits and one comma. The len function counts all characters.

[[asString(1234.5678)]]

1,234.57

The input number would be displayed as 1,234.57 in the project output, so the returned string shows the same.

[[len(asString(1234.5678))]]

8

The produced string (1,234.57) contains six digits, one comma, and one period. The len function counts all characters.

If you want a number represented as a string in a different format (e.g. without commas and periods), use a formatting function like numberFormat prior to the number-to-string conversion. For example:

ATL in Script

Result

[[asString(numberFormat(100000,'####'))]]

100000

[[len(asString(numberFormat(100000,'####')))]]

6

[[asString(numberFormat(1234.5678,'####'))]]

1235

[[len(asString(numberFormat(1234.5678,'####')))]]

4