请问关于Format函数的详细中文帮助 (25分)

  • 主题发起人 kelaocai
  • 开始时间
K

kelaocai

Unregistered / Unconfirmed
GUEST, unregistred user!
请问delphi中关于Format函数的详细中文帮助 英文的看不太明白,谢谢!
 
C

CJ

Unregistered / Unconfirmed
GUEST, unregistred user!
什么意思?
D:/>FORMAT /?
Formats a disk for use with Windows 2000.
FORMAT volume [/FS:file-system] [/V:label] [/Q] [/A:size] [/C] [/X]
FORMAT volume [/V:label] [/Q] [/F:size]
FORMAT volume [/V:label] [/Q] [/T:tracks /N:sectors]
FORMAT volume [/V:label] [/Q] [/1] [/4]
FORMAT volume [/Q] [/1] [/4] [/8]
volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
/FS:filesystem Specifies the type of the file system (FAT, FAT32, or NTFS).
/V:label Specifies the volume label.
/Q Performs a quick format.
/C Files created on the new volume will be compressed by
default.
/X Forces the volume to dismount first if necessary. All opened
handles to the volume would no longer be valid.
/A:size Overrides the default allocation unit size. Default settings
are strongly recommended for general use.
NTFS supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K.
FAT supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
(128K, 256K for sector size > 512 bytes).
FAT32 supports 512, 1024, 2048, 4096, 8192, 16K, 32K, 64K,
(128K, 256K for sector size > 512 bytes).
Note that the FAT and FAT32 files systems impose the
following restrictions on the number of clusters on a volume:
FAT: Number of clusters <= 65526
FAT32: 65526 < Number of clusters < 268435446
Format will immediately stop processing if it decides that
the above requirements cannot be met using the specified
cluster size.
NTFS compression is not supported for allocation unit sizes
above 4096.
/F:size Specifies the size of the floppy disk to format (160,
180, 320, 360, 640, 720, 1.2, 1.23, 1.44, 2.88, or 20.8).
/T:tracks Specifies the number of tracks per disk side.
/N:sectors Specifies the number of sectors per track.
/1 Formats a single side of a floppy disk.
/4 Formats a 5.25-inch 360K floppy disk in a
high-density drive.
/8 Formats eight sectors per track.
 
O

oldnew

Unregistered / Unconfirmed
GUEST, unregistred user!
他问的可是delphi中的format函数噢……
 
K

kelaocai

Unregistered / Unconfirmed
GUEST, unregistred user!
赫赫,是啊,我说的是delphi中的Format函数!
 
N

net_2002

Unregistered / Unconfirmed
GUEST, unregistred user!
?????晕!!!
 

老人家

Unregistered / Unconfirmed
GUEST, unregistred user!
英文的?
 
L

linuxer

Unregistered / Unconfirmed
GUEST, unregistred user!
Format函数
单元:SysUtils
种类:string formatting routines
定义:function Format(const Format: string;
const Args: array of const): string;
功能:Format从一个Pascal格式字符串和一系列的数组变量中返回一个格式化了的字符串。
这个函数格式化一个打开了的数组Args中的系列变量。格式化受Object Pascal格式化字符
串Format的控制,结果是作为一个Pascal字符串。

 
G

gear1023

Unregistered / Unconfirmed
GUEST, unregistred user!
还是看几个例子最实用。
 
L

langdx

Unregistered / Unconfirmed
GUEST, unregistred user!
这是DOS系统下的FORMAT命令使用参数方法。
原文所列为在2000下格式化磁盘参数格式,[]内为可选项
volume 指驱动器盘符,如A盘,表示为a:,要跟冒号
/FS:filesystem 指定文件系统类型,即FAT呀NTFS等
/V:label 指定驱动盘符标签名
/Q 执行快速格式化
/C 默认压缩时产生文件
/X 必要时强迫驱动盘不计数
/A:size 默认章元大小,下面是几种文件类型下的支持大小
/F:size 指定软盘大小
/T:tracks 指定每边磁盘的道数
/N:sector 指定每道的节数
/1 格式化软盘的一边
/4 在一个高密度驱动器内格式化5。25英寸360k软盘
/8 每磁道格式成8节
 
S

SY0331

Unregistered / Unconfirmed
GUEST, unregistred user!
linuxer: 是否可以告诉我, 如果在Format的格式字符串中有%(不作格式符号,
而是直接输出)该如何写,我没查到相关的描述。
 

网事如风

Unregistered / Unconfirmed
GUEST, unregistred user!
借花献佛,呵呵
格式化字符串
------------
function Format(const Format: string;
const Args: array of const): string;
Format字符串说明:
"%" [index ":"] ["-"] [width] ["." prec] type
(1) 格式化字符串必须以%开头
(2) [index ":"] 索引指的是Args参数列表中要显示的每一项的序号。比如:Args是
['a', 'c'],那么'a'的索引就是0,而'c'的索引就是1,而且由于只有
两项,所以就不会出现大于1的索引值。
Format('%2:s %1:s %0:s', ['1st', '2nd', '3rd']);
结果:'3rd 2nd 1st'
(3) ["-"] 这个标识符的作用是当要显示的字符的个数少于[width]时,在右边填补空格;
如果没加上["-"],则在左边填补空格。
Format('(%4s)', ['aa']);
结果:' aa'
(4) [width] 宽度
规定了要显示的字符的个数。如果要显示的宽度大于[width],则按实际的
宽度来显示;反之,则填补空格或按要求填补其它字符。
(5) ["." prec] 精度
这是针对浮点数来说的,一般就是指小数点后的位数。
(6) type 类型(见下面)
type的可能值有下列这些:
(1) d 有符号十进制数
Args必须是有符号整型数。如果在格式化字符串中还加入了["." prec],则如果Args
的长度如果小于给出的精度数时,在前边填补0;如果大于精度数,按实际长度显示。
Format('(%.3d)', [99]);
结果:'(099)'
(2) u 无符号十进制数
Args必须是无符号整型数。其它特性与d一样。
(3) e 科学技术法
用科学技术法显示数据,形式大致如下:'-d.ddd...E+ddd'。
Args必须是一个浮点数。如果是一个负数,则在最前面显示一个符号;在小数点前面
总是显示一位数字;包括小数点前面的数字在内,数字的个数由["." prec]来确定,
如果没有指定["." prec],则默认为15位精度。如果实际的数字长度超出了指定的
["." prec],则刚刚超出的那一位数字四舍五入。指数符号E后面总是要跟着加号或
减号,并且在后面至少跟着三位数字。
(4) f 固定的
Args必须为浮点数,转换后的形式大致是'-ddd.ddd...'这样的。
如果要转换的是负值,则前面有一个负号。转换后的数字,在小数点后面的数字的个数
由["." prec]决定。如果没有指定["." prec],默认为2位精度。
(5) g 一般的
Args必须为浮点数。
被转换后的数字总是尽可能的简短(有可能是f或e形式的)。有重要意义的数字的长度
由["." prec]来决定,默认为15位(包括整数位和小数位)。数字前后的0都将被去掉,
小数点也只有在必要的时候才显示出来。如果小数点左边的数字小于等于指定的精度,
并且整个值大于或等于0.00001的时候,才使用f的显示格式,否则使用e(科学技术法)
(6) n Args必须是浮点数。形式和f是一样的,不同的是会显示千位符,如:1,123,444
(7) m 货币类型
Args必须是浮点数。能够显示货币符号,可以通过“控制面板”来设置。小数点后
的位数由["." prec]决定,如果没用["." prec],则默认2位。
(8) p 指针
Args必须是一个指针值。
将指针转换为8个字符的十六进制字符串。
(9) s 字符串
Args必须是字符,字符串或PChar值。
如果指定了["." prec],并且字符串的实际长度大于["." prec],则从左到右截取
精度指定数量的字符串,其余的删除。
(10) x 十六进制
Args必须是一个整型数。
如果使用了["." prec],不足部分要用0补齐。
注意:[index ":"] [width] ["." prec]可以使用这样的格式:
Format('%*.*f', [8, 2, 123.456])
等价于:Format('%8.2f', [123.456]).


 

网事如风

Unregistered / Unconfirmed
GUEST, unregistred user!

补充一个常用的 formatdatatime
function FormatDateTime(const Format: string;
DateTime: TDateTime): string;
overload;
function FormatDateTime(const Format: string;
DateTime: TDateTime;
const FormatSettings: TFormatSettings): string;
overload;
根据Format的格式将DateTime(如 now)转换成相应的格式。
如果Format为空, TDateTime的值会依照 ShortDateFormat 显示.第一个函数是线程不安全的。
第二个是线程安全的。但需要设好format 参数。
format的对应值及意义如下。
Specifier Displays
c Displays the date using the format given by the ShortDateFormat global variable, followed by the time using the format given by the LongTimeFormat global variable. The time is not displayed if the date-time value indicates midnight precisely.
d Displays the day as a number without a leading zero (1-31).
dd Displays the day as a number with a leading zero (01-31).
ddd Displays the day as an abbreviation (Sun-Sat) using the strings given by the ShortDayNames global variable.
dddd Displays the day as a full name (Sunday-Saturday) using the strings given by the LongDayNames global variable.
ddddd Displays the date using the format given by the ShortDateFormat global variable.
dddddd Displays the date using the format given by the LongDateFormat global variable.
e (Windows only) Displays the year in the current period/era as a number without a leading zero (Japanese, Korean and Taiwanese locales only).
ee (Windows only) Displays the year in the current period/era as a number with a leading zero (Japanese, Korean and Taiwanese locales only).
g (Windows only) Displays the period/era as an abbreviation (Japanese and Taiwanese locales only).
gg (Windows only) Displays the period/era as a full name. (Japanese and Taiwanese locales only).
m Displays the month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mm Displays the month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mmm Displays the month as an abbreviation (Jan-Dec) using the strings given by the ShortMonthNames global variable.
mmmm Displays the month as a full name (January-December) using the strings given by the LongMonthNames global variable.
yy Displays the year as a two-digit number (00-99).
yyyy Displays the year as a four-digit number (0000-9999).
h Displays the hour without a leading zero (0-23).
hh Displays the hour with a leading zero (00-23).
n Displays the minute without a leading zero (0-59).
nn Displays the minute with a leading zero (00-59).
s Displays the second without a leading zero (0-59).
ss Displays the second with a leading zero (00-59).
z Displays the millisecond without a leading zero (0-999).
zzz Displays the millisecond with a leading zero (000-999).
t Displays the time using the format given by the ShortTimeFormat global variable.
tt Displays the time using the format given by the LongTimeFormat global variable.
am/pm Uses the 12-hour clock for the preceding h or hh specifier, and displays 'am' for any hour before noon, and 'pm' for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
a/p Uses the 12-hour clock for the preceding h or hh specifier, and displays 'a' for any hour before noon, and 'p' for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
ampm Uses the 12-hour clock for the preceding h or hh specifier, and displays the contents of the TimeAMString global variable for any hour before noon, and the contents of the TimePMString global variable for any hour after noon.
/ Displays the date separator character given by the DateSeparator global variable.
: Displays the time separator character given by the TimeSeparator global variable.
'xx'/"xx" Characters enclosed in single ordo
uble quotes are displayed as-is, anddo
not affect formatting.


 
M

majorsoft

Unregistered / Unconfirmed
GUEST, unregistred user!
感谢往事如风提供资料。
补充一个常用的 formatdatatime
function FormatDateTime(const Format: string;
DateTime: TDateTime): string;
overload;
function FormatDateTime(const Format: string;
DateTime: TDateTime;
const FormatSettings: TFormatSettings): string;
overload;
根据Format的格式将DateTime(如 now)转换成相应的格式。
如果Format为空, TDateTime的值会依照 ShortDateFormat 显示.第一个函数是线程不安全的。
第二个是线程安全的。但需要设好format 参数。
因为这个很常用我翻译了一下,如有错误,请指正。
format的对应值及意义如下。
指定值显示
c 用全局变量ShortDateFormat提供的格式显示日期,接着用全局变量LongTimeFormat提供的格式显示时间。如果date-time的值精确指示午夜的话,时间不会显示。
d 以非0打头的数字(1-31)显示天
dd 以0打头的数字(01-31)显示天
ddd 以全局变量ShortDayNames提供的字符串的简写(Sun-Sat)显示天。
dddd 以全局变量LongDayNames提供的字符串的全称(Sunday-Saturday)显示天。
ddddd 使用由全局变量ShortDateFormat提供的格式显示天。
dddddd 使用由全局变量LongDateFormat提供的格式显示天。
e (只适合Windows)以非0打头的数字显示日期(只适用日本,朝鲜,台湾地区)
ee (只适合Windows)以0打头的数字显示日期(只适用日本,朝鲜,台湾地区)
g (只适合Windows)以简写的方式显示日期(只适用日本,台湾地区)
gg (只适合Windows)以全称的方式显示日期(只适用日本,台湾地区)
m 以非0打头的数字(1-12)显示月,如果m后紧跟h或hh,那么是显示分钟而不是月。
mm 以0打头的数字(01-12)显示月,如果mm后紧跟h或hh,那么是显示分钟而不是月。
mmm 使用由全局变量ShortMonthNames提供的格式的简写(Jan-Dec)显示月。
mmmm 使用由全局变量LongMonthNames提供的格式的全称(January-December)显示月。
y 以两位数字(00-99)显示年。
yy 以四位数字(0000-9999)显示年。
h 以非0打头的数字(0-23)显示时
hh 以0打头的数字(00-23)显示时
n 以非0打头的数字(0-59)显示分
nn 以0打头的数字(00-59)显示分
s 以非0打头的数字(0-59)显示秒
ss 以0打头的数字(0-59)显示秒
z 以非0打头的数字(0-999)显示毫秒
zzz 以0打头的数字(0-999)显示毫秒
t 使用全局变量ShortTimeFormat提供的格式显示时间
tt 使用全局变量LongTimeFormat提供的格式显示时间
am/pm 为前面的h指示器使用12小时时钟,并且在中午之前的小时之前显示'am',在中午之前的小时之后显示'pm',am/pm 可以使用小写,大写,或混合方式,结果也以相应的方式显示。
a/p 为前面的h指示器使用12小时时钟,并且在中午之前的小时之前显示'a',在中午之前的小时之后显示'p',a/p 可以使用小写,大写,或混合方式,结果也以相应的方式显示。
ampm 为前面的h指示器使用12小时时钟,在中午之前的小时后面显示全局变量TimeAMString的内容,在中午之后的小时后面显示全局变量TimePMString的内容
/ 显示由全局变量DateSeparator提供的日期分割符
:显示由全局变量TimeSeparator提供的时间分割符
包含单引号和双引号的'xx'/"xx" 字符显示为as-is,不会影响格式

 
顶部