例子 <参见strnew>
━━━━━━━━━━━━━━━━━━━━━
首部 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=%.*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); //连接字符串
参考 proceduer sysutils.fmtstr
例子 edit1.text := format(edit2.text, [strtofloatdef(edit.3.text, 0)]);
━━━━━━━━━━━━━━━━━━━━━
首部 procedure fmtstr(var result: string; const format: string; const args:
array of const); $[sysutils.pas
功能 按指定方式格式化一个数组常量的字符形式返回
说明 <参见format>
参考 function sysutils.formatbuf;function system.length;function
system.setlength
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 function strfmt(buffer, format: pchar; const args: array of const):
pchar; $[sysutils.pas
功能 返回按指定方式格式化一个数组常量的字符指针形式
说明 如果buffer和format其中只要有一个为nil则返回nil
参考 function sysutils.formatbuf
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 function strlfmt(buffer: pchar; maxbuflen: cardinal; format: pchar;
const args: array of const): pchar; $[sysutils.pas
功能 返回按指定方式和长度格式化一个数组常量的字符指针形式
说明 strlfmt(vbuffer, 6, '%d|12345', [1024]) = '1024|1';
参考 function sysutils.formatbuf
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 function formatbuf(var buffer; buflen: cardinal; const format; fmtlen:
cardinal; const args: array of const): cardinal; $[sysutils.pas
功能 返回按指定方式格式化一个数组常量到缓冲区buffer中
说明 <null>
参考 <null>
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 function wideformat(const format: widestring; const args: array of
const): widestring; $[sysutils.pas
功能 返回按指定方式格式化一个数组常量的多字节字符形式
说明 <null>
参考 procedure sysutils.widefmtstr
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 procedure widefmtstr(var result: widestring; const format: widestring;
const args: array of const); $[sysutils.pas
功能 按指定方式格式化一个数组常量的多字节字符形式返回
说明 <null>
参考 function sysutils.wideformatbuf
例子 <参见format>
━━━━━━━━━━━━━━━━━━━━━
首部 function wideformatbuf(var buffer; buflen: cardinal; const format;
fmtlen: cardinal; const args: array of const): cardinal; $[sysutils.pas
功能 返回按指定方式格式化一个数组常量到缓冲区buffer中
说明 <null>
参考 <null>