Home Contents | # string.using | String | Core4 Lua Commands

## SYNOPSIS

result = string.using(number [, len [, pad [, base [, format [, decimals]]]]])

## DESCRIPTION

Formats the integer number into a string. The value of len determines the length of the result. pad indicates the character code used for padding. The number base is given by base, which defaults to 10. The format controls sign processing.

If len is given but pad is absent or nil, the length is a maximum limit. If pad is given, the result is always padded or truncated to the exact value of len. When pad is an ascii zero character (48), any sign character is moved to the start of the result, for any other character the sign is placed just in front of the unpadded number.

The possible range of base is 2 .. 36, using the upper-case letters A...Z for any digit value larger than 9.

The format can either be "" (default, format an unsigned number), "-" (Add a sign only if the number is negative) or "+" (Always add a sign).

If decimals is given, the resulting string will have a decimal point added so the result has decimals decimal places.

## RETURN VALUE

Returns a string.

## EXAMPLE

> >
print(string.using(1234, 10, 48, nil, "+")) print(string.using(1234, 10, 46, nil, "+"))
+000001234 .....+1234