[↑]
SmileBASIC4 Replica Reference
FORMAT$
Format the value into a string using the display format

FORMAT$(FormatString,Value,...)

Argument

FormatString

A string to be formatted and embedded

・Control the value formatting method by adding the following type specification or auxiliary specification after %.

%S Outputs the contents of a string variable
%D Decimal Int Output
%X Hexadecimal Int Output
%F Real Output
%B Binary Int Output
%% Output the Character %

Format string auxiliary specification

Format the output by specifying the following auxiliary specification after %

・Number of digits specification: Specify the number of digits (%8D,%4X)
・Specify the number of decimal places: The total number of digits, the number of digits in the decimal part (%8.2F)
・Blank padding: Specify a space character + number of digits (% 4D → "   0")
・Zero padding: Specify 0 + number of digits (%08D → "00000000")
・Left alignment: Specify -symbol + number of digits (%-8D)
・+Sign display: Specify +symbol + number of digits (%+8D)

Value

・Specify the value to be formatted and converted into a string as many arguments as the % specified in the format string (excluding %%).
・An error occurs if the % specification does not match with the type expected and the argument type.

Return Value

Generated string

Example

S$=FORMAT$("%06D",A)
About this site
Our site is an unofficial manual site of programming software "SmileBASIC" for NintendoSwitch™.
I acquire the content of the site from the official reference site of the SmileBoom Co.Ltd. that is the development and sales cause of the software in real time (a minimum period of 24 hours update) and display it. For automatic update, contents may become improper.
Please confirm the correct content in an official site.

June 3, 2020
by mim
OK
|