Equinox Online Help - Language Reference - A to Z

Home

Str

Applies to
SyntaxStr(NumberExpression, [LengthExpression ],[DecimalsExpression], [FormatExpression])
Action[Function] Returns a specified number as a string.
ScopeUsable anywhere.
Notes

This function converts NumberExpression into a string format. eg 23 becomes "23". FormatExpression (optional) determines the style of the returned string. Possible values of FormatExpression (the default is zero) are:

  • 0 No trailing spaces or zeros, leading spaces or zeros, or comma separators are included
  • 1 Trailing zeros are included
  • 2 Leading zeros are included
  • 4 Comma separators are included
  • 8 Trailing spaces are included
  • 16 Leading spaces are included

You may add any of these values together to make combined formats. eg A value of five would produce a string with trailing zeros and comma separators. Note that if you specify both leading zeros and spaces, or following zeros and spaces, Equinox uses spaces only.

LengthExpression and DecimalsExpression specify the string length and number of decimal places that are included. If you omit LengthExpression, then Equinox uses the minimum size required to fit in the whole number. If you omit DecimalsExpression then they are all included. If you want to include trailing or leading characters (specified in FormatExpression) you must include both optional arguments, as Equinox uses them to determine how many leading/ trailing characters to include.

CategoryConversions
See Also Asc, Card, ChoosePrinter, HexNum, HexStr, Lowercase, Ord, StrCase, StrDate, StrTime, Uppercase
Example

In the following examples, the notes show what is printed (in the Print window) by each statement.

Print Str (421, , , 0) | "421"
Print Str (1.75, 1, 1, 0) | "1.8"
Print Str (1.75, 1, 0, 0) | "2"
Print Str (23659, 5, 2, 5) | "23,659.00"
Print Str (14,6, , 2) | "000014"
Print Str (14,6, , 16) | " 14"
Print Str (14.3, 5, 4, 3) | "00014.3000"
Print Str (14.3, 5, 4, 24) | " 14.3 "
Print Str (14, 1, 0, 0) | "*"

The last example shows what happens when the string size is too short. The function returns an asterisk character.