Format Function
来源:互联网 发布:sql删除指定表的数据 编辑:程序博客网 时间:2024/05/22 20:58
function Format(const Format: string; const Args: array of const): string; $[SysUtils.pas
功能 返回按指定方式格式化一个数组常量的字符形式
说明 这个函数是我在Delphi中用得最多的函数,现在就列举几个例子给你个直观的理解
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]); //'x=12' //最普通
Format('x=%3d', [12]); //'x= 12' //指定宽度
Format('x=%f', [12.0]); //'x=12.00' //浮点数
Format('x=%.3f', [12.0]); //'x=12.000' //指定小数
Format('x=%8.2f'[12.0]) // 'x= 12.00' ;
Format('x=%.*f', [5, 12.0]); //'x=12.00000' //动态配置
Format('x=%.5d', [12]); //'x=00012' //前面补充0
Format('x=%.5x', [12]); //'x=0000C' //十六进制
Format('x=%1:d%0:d', [12, 13]); //'x=1312' //使用索引
Format('x=%p', [nil]); //'x=00000000' //指针
Format('x=%1.1e', [12.0]); //'x=1.2E+001' //科学记数法
Format('x=%%', []); //'x=%' //得到"%"
S := Format('%s%d', [S, I]); //S := S + StrToInt(I); //连接字符串
==========
,C Char, 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 structures.
,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 indicated expression.
For example, to display the first four bytes starting at the memory address, type 4M.
If n is not specified, it defaults to the size in 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.
功能 返回按指定方式格式化一个数组常量的字符形式
说明 这个函数是我在Delphi中用得最多的函数,现在就列举几个例子给你个直观的理解
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]); //'x=12' //最普通
Format('x=%3d', [12]); //'x= 12' //指定宽度
Format('x=%f', [12.0]); //'x=12.00' //浮点数
Format('x=%.3f', [12.0]); //'x=12.000' //指定小数
Format('x=%8.2f'[12.0]) // 'x= 12.00' ;
Format('x=%.*f', [5, 12.0]); //'x=12.00000' //动态配置
Format('x=%.5d', [12]); //'x=00012' //前面补充0
Format('x=%.5x', [12]); //'x=0000C' //十六进制
Format('x=%1:d%0:d', [12, 13]); //'x=1312' //使用索引
Format('x=%p', [nil]); //'x=00000000' //指针
Format('x=%1.1e', [12.0]); //'x=1.2E+001' //科学记数法
Format('x=%%', []); //'x=%' //得到"%"
S := Format('%s%d', [S, I]); //S := S + StrToInt(I); //连接字符串
==========
,C Char, 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 structures.
,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 indicated expression.
For example, to display the first four bytes starting at the memory address, type 4M.
If n is not specified, it defaults to the size in 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.
- Format Function
- Javascript format日期function
- jQuery String Template Format Function
- d.jgrid.format is not a function
- iOS可变参数和Format Function
- A high performance string format function for JavaScript
- Just another high performance string format function for JavaScript
- Call to a member function format() on string
- Format
- Format
- format
- Format
- Format
- Format
- format
- format
- Format()
- Format
- [转载]SDL Guide 中文译版
- oracle中查询及删除重复记录的sql
- Zip access db
- "可复用代码管理器 v1.0 Beta"发布
- 无损数据压缩
- Format Function
- 关于Zombies和Script Kiddies:分布式拒绝服务攻击
- Using google Downloading what you wants
- [转贴]GNU 库通用公共许可证
- 压力测试-概念澄清及如何测试
- 在SQL*PLUS中建立、调用函数
- 《多媒体技术基础》辅导
- 一个讨论web测试的论坛地址
- [装载]SDL:使 Linux 变得有趣