SysUtilsFormat (Delphi)
Description
This example uses several edit boxes and a button on a form. After filling in input data into the edit boxes, press the Format button to display the resulting formatted string.
Code
procedure TForm1.Button1Click(Sender: TObject);
var
signed_integer: Integer;
hexa_integer: Integer;
floating_point: Extended;
text: String;
begin
{ Extract the data from the edit boxes. }
text := Edit1.Text;
signed_integer := StrToInt(Edit2.Text);
hexa_integer := StrToInt(Edit3.Text);
floating_point := StrToFloat(Edit4.Text);
{
Format the data using the following rules:
* Only the first three characters of text are displayed.
* Signed_integer is displayed as a signed integer
with ten padding zeros.
* Hexa_integer is displayed in hexadecimal with eight padding zeros.
* Floating_point is displayed as a fixed point value,
using a width of 10 and a precision of two digits.
}
Edit5.Text :=
Format('%.3s, %.10d, $%.8x, %10.2f',
[text, signed_integer, hexa_integer, floating_point]);
end;
Uses
- System.SysUtils.Format ( fr | de | ja )
- System.AnsiStrings.Format ( fr | de | ja )