FutureBasic Logo

<<    Index    >> FutureBasic

using   function



Syntax
PascalString = using FormatPascalString;expr

Description
This function returns a decimal string representation of the numeric expr, formatted according to specifications in FormatPascalString. The characters in FormatPascalString are interpreted as follows:

SpecifierDescription
.This represents a decimal point. In the returned string, the "." is replaced by the currently defined decimal point symbol (which is just a period, if Def Using has never been executed). This specifier also indicates where the integer part of expr should be separated from the fractional part in the returned string. If there is more than one "." character in FormatPascalString, only the first one is interpreted as a decimal point specifier. If FormatPascalString does not contain a "." specifier, then only the integer part of expr will be represented in the returned string. Note that "." is interpreted somewhat differently if the "^^^^" specifier is also used.
#Each "#" that appears to the left of the "." specifier is replaced by a digit from the integer part of expr, or (if there are excess "#" specifiers) by a blank space. Each "#" that appears to the right of the "." specifier is replaced by a digit from the fractional part of expr, or (if there are excess "#" specifiers) by a "0" character. There must be at least enough "#" specifiers to the left of the "." to represent the integer part of expr. If there are too few "#" specifiers to the right of the "." to represent the fractional part, the value of expr is rounded to the indicated number of digits. Note that "#" is interpreted somewhat differently if the "^^^^" specifier is also used.
*This is treated the same as the "#" specifier, except that if there are excess "*" specifiers to the left of the ".", the excess specifiers are replaced by "*" characters rather than by blank spaces.
,Each occurrence of "," which appears after the first "#" or "*" is interpreted as a thousands separator. If there are enough digits in expr to fill at least one of the "#" or "*" specifiers to the left of the ",", then the "," is replaced by the currently defined thousands-separator symbol (which is just a comma, if Def Using has never been executed); otherwise, the "," is replaced by a blank space.
$If "$" appears to the left of the leftmost "#" or "*" specifier, it's replaced by the currently defined currency symbol (which is just a dollar sign, if Def Using has never been executed). However, if this would cause blank spaces to appear between the currency symbol and the number, then the currency symbol is moved to the right until there are no intervening blank spaces.
+This is replaced by a "+" if expr is positive, or by a "-" if expr is negative. As with "$", the symbol may be moved to the right to eliminate intervening blank spaces.
-This is replaced by a blank space if expr is positive, or by a "-" if expr is negative. As with "$", the symbol may be moved to the right to eliminate intervening blank spaces. This specifier is most useful if you want the "-" to appear in a non-standard location; if you use neither the "-" nor the "+" specifier, and expr is negative, and there is a sufficient number of "#" symbols used as placeholders, a "-" will always appear to the left of the number.
^^^^This specifier causes expr to be represented in scientific notation. The "^^^^" characters will be replaced by an exponent expression, in the form "E+nn" or "Enn". When you use the "^^^^" specifier, the leftmost "#" specifier may not be used to specify digits to the left of the decimal in FormatPascalString because "Standard" scientific notation places one nonzero digit before the decimal point
^^^^^This is the same as the "^^^^" specifier, but it allows for up to 3 digits in the exponent. You should use this specifier whenever there's a chance that the exponent could exceed ±99.

If FormatPascalString contains any characters other than the specifiers listed above, they are transferred unaltered to the returned string.

Example
x = 14.726
print using "You owe me $#,###.##."; x

program output:
You owe me $14.73.

See also
str$; uns$