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.
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 用了维a酸乳膏过敏怎么办 药水点痣留下的红印怎么办 小孩牙齿被虫子吃了个洞怎么办 一岁宝宝贫血值是84怎么办 荒岛求生手机版被困在石室里怎么办 工伤认定期间被厂里辞退工资怎么办 怀孕50天看恐怖片肚子阴痛怎么办 欧卡二进游戏就卡画面了怎么办 魅族手机的微信图标找不到了怎么办 金立手机:微信图标找不到怎么办? 鞋厂装跟机老是卡钉怎么办 苹果手机摔了一下开不了机怎么办 百度网盘解析的种子保存不了怎么办 下载了种子百度网盘解析不了怎么办 正畸复诊后吃饭一直会磨嘴怎么办 遇到儿子说话对母亲不满母亲怎么办 冰箱旧了怎么办教你创新冰箱翻新法 微信陌生人加好友发红包怎么办 微信红包发了对方收不到怎么办 发红包是微信密码不知道了该怎么办 微信上红包密码不知道密码怎么办 本人不知道微信自动发红包怎么办 微信钱包里的钱没了怎么办 微信聊天删除了红包没领怎么办 微信红包未领取删掉了怎么办 微信红包没领取删掉了怎么办 微信红包没领取就删除好友了怎么办 老公一个人出去玩不愿带老婆怎么办 干了一年也攒不下钱怎么办 住院出院后请领导同事吃饭怎么办 有同事请吃饭答应了又不想去怎么办 同事请吃饭发红包不收怎么办 同事要走了请吃饭我不想去怎么办 请领导吃饭他说今晚有事我该怎么办 两个月的狗狗不吃狗粮怎么办 挖机驾驶室的小镙杆总是掉该怎么办 开挖机出了事故没有证怎么办 发现小孩有早恋现象做家长该怎么办 马上中考了初三孩子不上学怎么办 初三孩子老说自己难受不上学怎么办 幼儿园安全教案迷路了怎么办及反思