Инструменты пользователя

Инструменты сайта


en:tcmediainfo:documentation:script_strformat

StrFormat

Function return string formatted by specificators.

StrFormat(format [, value1 [, value2 .. [, valueN]]])
formatFormat string, can contain specificators and auxillary text.
value1..NList of values.

In common specificator format is:

"%" [index ":"] ["-"] [width] ["." prec] type

Specificator starting with % symbol, followed with:

  • optional parameter [index «:»], defining argument index;
  • optional Indicator of left aligning [«-»];
  • optional parameter [width], defining minimal length of result string;
  • optional parameter [«.» prec], definging precision;
  • symbol of conversion type, type.

List of conversion types:

dDecimal. The argument must be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros.
uUnsigned decimal. Similar to d, but no sign is output.
eScientific. The argument must be a floating-point value. The value is converted to a string of the form «-d.ddd…E+ddd». The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string; a default precision of 15 is assumed if no precision specifier is present. The «E» exponent character in the resulting string is always followed by a plus or minus sign and at least three digits.
fFixed. The argument must be a floating-point value. The value is converted to a string of the form «-ddd.ddd…». The resulting string starts with a minus sign if the number is negative. The number of digits after the decimal point is given by the precision specifier in the format string—a default of 2 decimal digits is assumed if no precision specifier is present.
gGeneral. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string; a default precision of 15 is assumed if no precision specifier is present. Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses the fixed-point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format.
nNumber. The argument must be a floating-point value. The value is converted to a string of the form «-d,ddd,ddd.ddd…». The n format corresponds to the f format, except that the resulting string contains thousand separators.
sString. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.
xHexadecimal. The argument must be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros.

Remarks

For compatibility, function have Format alias.

en/tcmediainfo/documentation/script_strformat.txt · Последние изменения: 2019/08/19 21:31 — loopback

Инструменты страницы