Substring.Format Method

Overload List

#SignatureDescription
1class function Format(const Format: string; const Args: array of const): Substr.Substring; overload; static;The format text with Args written into it.
2class function Format(const Format: string; const Args: array of const; const AFormatSettings: TFormatSettings): Substr.Substring; overload; static;

Overload 1: class function Format(const Format: string; const Args: array of const): Substr.Substring; overload; static;

The format text with Args written into it.

#NameDescription
1Format

The format text, every text kind.

2Args

The arguments; the AFormatSettings form takes its separators and currency from the settings given, the other from FormatSettings.

Returns: Substring - The formatted text, sized once.

Remarks:

Directives: %[index:][-][width][.precision]type; floats are correctly rounded. A directive invalid or incompatible with its argument, a missing argument, or an AnsiString, Variant or object argument raises EConvertError.

Examples

Numbers, texts and a float with explicit settings.

uses Substr, System.SysUtils;

procedure Example;
var fs: TFormatSettings;
begin
    Assert(Substring.Format('%d:%s', [7, 'x']) = '7:x');
    fs := FormatSettings;
    fs.DecimalSeparator := '.';
    Assert(Substring.Format('%.1f', [1.26], fs) = '1.3');
end;
See Also: Substring.Format, Substring.Format

Overload 2: class function Format(const Format: string; const Args: array of const; const AFormatSettings: TFormatSettings): Substr.Substring; overload; static;

#NameTypeDescription
1Formatstring
2Argsarray of const
3AFormatSettingsTFormatSettings

Returns: Substring