<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > BuiltIn Functions > String functions > USING$ |
Description
Format numeric or string expressions according to instructions contained in a format expression.
Syntax
s = USING$(StringFormat, Expression)
Returns
String
Parameters
Name |
Type |
Optional |
Meaning |
StringFormat |
String |
No |
A string expression containing the format to apply |
Expression |
String or Numeric |
No |
A numeric or string expression |
Remarks
Character | Definition |
When Expression is a string expression, the following format codes apply within StringFormat:
Char |
Meaning |
! |
The first character of the string is returned |
& |
The entire string is returned. |
\\ |
The first two characters are returned. |
\ \ |
If backslashes enclose n spaces, n + 2 characters of the string expression are returned. |
_ |
Escape (underscore) character. The following character is interpreted as a literal character instead of a mask format character. |
When Expression is a numeric expression, the following format codes apply within StringFormat:
Char |
Meaning |
# |
A numeric digit position, which is space-filled to the left, and zero-filled to the right of the decimal point. If the number is negative, a minus sign occupies a digit position. |
. |
The decimal point is placed at this position. |
, |
A numeric digit position, which signifies that whole number digits should be displayed with a comma each three digits. |
$$ |
Two numeric digit positions which cause a dollar sign to be inserted immediately before the number. |
*x |
Two numeric digit positions which cause leading blank spaces in the field to be replaced with the character in the second position of the pair "x" (where "x" represents your own choice of character). For example, two asterisks "**" will convert leading spaces to asterisks, and "*=" converts leading spaces to equals characters, etc. The *x mask characters also act as two digit (#) placeholders. Your mask must contain at least three characters to use this. |
+ |
A plus at the start of the field causes the sign of the value (+ -) to be inserted before the number. A plus at the end of the field causes the sign of the value (+ -) to be added after the number. |
- |
A minus at the end of the field causes a minus signed to be added after a negative number, or a space to be added after a positive number. A minus at the start of the field is treated as a literal character, which is always inserted. |
^ |
Numbers can be formatted in scientific notation by including three to six carets (^) in the format string. Each caret corresponds to a numeric digit position in the exponent, one for E, one for the exponent sign, and one to four for the actual digits of the exponent value. |
_ |
Escape (underscore) character. The following character is interpreted as a literal character instead of a mask format character. Therefore, to include a literal underscore character in the format mask, use two underscore characters. |
Restrictions
See also
Examples