フォーマット文字列のコントロール下で、データを
シグネチャ
戻り値
説明
%32mまたは
%-15m) の引数に対するルールは、有効桁を指定しないことを除き、%s のルールと同様です。
例
例: 整数のフォーマット | |
{let i:int = 1234} {let j:int = -1234} {let k:int = 56} {Table columns = 4, cell-border-width = 2pt, {text Signed Decimal Integer}, {format "%d", i}, {format "%d", j}, {format "%d", k}, {text ... with {monospace +} modifier (sign)}, {format "%+d", i}, {format "%+d", j}, {format "%+d", k}, {text ... with {italic width} set to 1}, {format "%1d", i}, {format "%1d", j}, {format "%1d", k}, {text ... with {italic width} set to 8}, {format "%8d", i}, {format "%8d", j}, {format "%8d", k}, {text ... and {monospace 0} modifier (leading zeros)}, {format "%08d", i}, {format "%08d", j}, {format "%08d", k}, {text Unsigned Decimal Integer}, {format "%u", i}, {text N/A}, {format "%u", k}, {text Unsigned Octal Integer}, {format "%o", i}, {text N/A}, {format "%o", k}, {text ... with {monospace #} modifier}, {format "%#o", i}, {text N/A}, {format "%#o", k}, {text Unsigned Hexadecimal Integer}, {format "%x", i}, {text N/A}, {format "%x", k}, {text ... with {monospace #} modifier}, {format "%#x", i}, {text N/A}, {format "%#x", k}, {text Unsigned Binary Integer}, {format "%b", i}, {text N/A}, {format "%b", k}, {text ... with {monospace #} modifier}, {format "%#b", i}, {text N/A}, {format "%#b", k} } |
例
例: 浮動小数点数のフォーマット | |
{let i:double = 1357.6863} {let j:double = 36.69} {let k:double = -36.69} {Table columns = 4, cell-border-width = 2pt, {text Standard Notation}, {format "%f", i}, {format "%f", j}, {format "%f", k}, {text ... with {monospace +} modifier (sign)}, {format "%+f", i}, {format "%+f", j}, {format "%+f", k}, {text ... with {italic width} set to 2}, {format "%2f", i}, {format "%2f", j}, {format "%2f", k}, {text ... with {italic width} set to 8}, {format "%8f", i}, {format "%8f", j}, {format "%8f", k}, {text ... with {italic precision} set to 2}, {format "%.2f", i}, {format "%.2f", j}, {format "%.2f", k}, {text ... and {monospace 0} modifier (leading zeros)}, {format "%0.2f", i}, {format "%0.2f", j}, {format "%0.2f", k}, {text ... with {italic precision} set to 8}, {format "%.8f", i}, {format "%.8f", j}, {format "%.8f", k}, {text Scientific Notation (e)}, {format "%e", i}, {format "%e", j}, {format "%e", k}, {text Scientific Notation (E)}, {format "%E", i}, {format "%E", j}, {format "%E", k}, {text Mixed Notation}, {format "%g", i}, {format "%g", j}, {format "%g", k} } |
例
例: 文字列のフォーマット | |
{let s1:String = "Hello!"} {let s2:String = "Hello World!"} {let s3:String = "Hello World, here comes... Curl!"} {Table columns=4, cell-border-width=2pt, {text String}, {format "%s", s1}, {format "%s", s2}, {format "%s", s3}, {text ... with {italic width} set to 4}, {format "%4s", s1}, {format "%4s", s2}, {format "%4s", s3}, {text ... with {italic width} set to 26}, {format "%26s", s1}, {format "%26s", s2}, {format "%26s", s3}, {text ... with {italic precision} set to 4}, {format "%.4s", s1}, {format "%.4s", s2}, {format "%.4s", s3}, {text ... with {italic precision} set to 26}, {format "%.26s", s1}, {format "%.26s", s2}, {format "%.26s", s3} } |
例
例: 幅と精度でフォーマット | |
|| Declare and initialize an int, a float, and a string {let i:int = 12} {let f:float = 56.789f} {let s:String = "Hello World"} || Declare an initialize a variable that you can use for || the width and precision {let v:int = 4} || Format and output the int, float, and string using a || variable width {format "%0*d", v, i} {br}{format "%*f", v, f} {br}{format "%*s", v, s} || Change the value of the variable width and display || the int, float, and string {set v = 8} {format "%0*d", v, i} {br}{format "%*f", v, f} {br}{format "%*s", v, s} || Use variable precision {format "%0.*d", v, i} {br}{format "%.*f", v, f} {br}{format "%.*s", v, s} |
例
例: フォーマット引数インデックスの指定 | |
|| Output a string with two formatting characters: || - A string %s. || - A decimal number with a 2-digit width. {format "The %s concerns how computers deal with the year %02d", "Y2K problem", 0} || Output the same string; this time specifying the || rest arguments. {format "The %1!s! concerns how computers deal with the year %2!02d!", "Y2K problem", 0} || And finally, mix things up a bit. {format "The %2!s! concerns how computers deal with the year %1!02d!", 0, "Y2K problem"} |
注意事項