FORMAT function in delphi

xiaoxiao2021-03-06  38

Function Format (const format: string; const args: array of const): String; $ [sysutils.pas

Function Back to format a character form of a constant constant in the specified mode

Note This function is the most used function in Delphi, and now list several examples to give you an intuitive understanding.

"%" [Index ":"] ["-"] [width] ["." Summary] type

Format ('x =% d', [12]); // 'x = 12' // most common

Format ('x =% 3D', [12]); // 'x = 12' // Specify width

Format ('x =% f', [12.0]); // 'xi12.00' // floating point number

Format ('x =%. 3f', [12.0]); // '= 12.000' // Specify a decimal

Format ('x =% 8.2f' [12.0]) // 'x = 12.00';

Format ('x =%. * F', [5, 12.0]); // 'X=12.00000' // Dynamic configuration

Format ('x =%. 5D', [12]); // 'x = 00012' // front supplement 0

Format ('x =%. 5x', [12]); // 'x = 0000c' // hex

Format ('x =% 1: D% 0: D', [12, 13]); // 'x = 1312' // use index

Format ('x =% p', [NIL]); // 'x = 00000000' // pointer

Format ('x =% 1.1e', [12.0]); // '=1.2e 001' // scientific counting

Format ('x = %%', []); // 'x =%' // Get "%"

S: = format ('% s% d', [s, i]); // s: = s strt (i); // connection string

==========

, C, Strings Character. Shows Characters for Ascii 0 To 31 in The delphi Language #nn notation.

, S char, strings string. Shows ascii 0 to 31 in Delphi Language #nn notation.

, D Integers Decimal. Shows Integer Values ​​in Decimal Form, Including Those in Data Structures.

, H or, x integers Hexadecimal. Shows Integer Values ​​in Hexadecimal with The $ Prefix, Including Those in Data Structure.

, Fn Floating point Floating point. Shows n significant digits where n can be from 2 to 18. For example, to display the first four digits of a floating-point value, type, F4. If n is not specified, the default is 11 ., P Pointers pointer. Shows pointers as 32-bit addresses with additional information about the address pointed to. It tells you the region of memory in which the pointer is located and, if applicable, the name of the variable at the offset address.

, R Records, Classes, Records / Classes / Objects. Shows Both Field Names and

Objects Values ​​Such As (x: 1; Y: 10; Z: 5) INSTEAD OF (1, 10, 5).

, NM All Memory Dump. Shows n bytes, Starting At the address of the indeicated expression.

For Example, To Display The First FourTes Starting At The Memory Address, Type 4M.

IT DEFAULTS to THE SIIN BYTES of the TYPE OF THE VARIABLE.

By Default, Each Byte Is Displayed As Two Hex Digits.

Use memory dump with the c, d, h, and s format specifiers to change the byte formatting.

转载请注明原文地址:https://www.9cbs.com/read-65276.html

New Post(0)