function Format(const Format: string; const Args: array of const): string; 功能 返回按指定方式格式化一个数组常量的字符形式
"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 类型
Format('x=%d', [12]); 
Format('x=%3d', [12]); 
Format('x=%f', [12.0]); 
Format('x=%.*f', [5, 12.0]); 
Format('x=%.5d', [12]); 
Format('x=%.5x', [12]); 
Format('x=%1:d%0:d', [12, 13]); 
Format('x=%p', [nil]); 
Format('x=%1.1e', [12.0]); 
Format('x=%%', []); 
可以帮我把上边的解释一下吗?具体的解释出:"%" [索引 ":"] ["-"] [宽度] ["." 摘要] 它们的意思,以及上面每一句Format()语句的意思。我要全面的、详细的、正确的。正确的话立马送分!

解决方案 »

  1.   

    %是前导符即x=后面的东西表示要有替代输出
    类型是里面象d,f,e这些东东。表示传输的类型
    这两个是必须的
      

  2.   

    ["." 摘要]这个说法有问题,最好说成[.,小数位数]好理解多了
    [宽度]就是这个后面参数代入字符串所占的宽度[索引 ":"] 没用过。help里的解释是An optional argument zero-offset index specifier (that is, the first item has index 0), [index ":"]
      

  3.   

    d Decimal. The argument must be an integer value. The value is converted to a string of decimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has less digits, the resulting string is left-padded with zeros.
    u Unsigned decimal. Similar to 'd' but no sign is output.
    e Scientific. The argument must be a floating-point value. The value is converted to a string of the form "-d.ddd...E+ddd". The resulting string starts with a minus sign if the number is negative. One digit always precedes the decimal point.The total number of digits in the resulting string (including the one before the decimal point) is given by the precision specifier in the format string梐 default precision of 15 is assumed if no precision specifier is present. The "E" exponent character in the resulting string is always followed by a plus or minus sign and at least three digits.
    f Fixed. The argument must be a floating-point value. The value is converted to a string of the form "-ddd.ddd...". The resulting string starts with a minus sign if the number is negative.The number of digits after the decimal point is given by the precision specifier in the format string梐 default of 2 decimal digits is assumed if no precision specifier is present.
    g General. The argument must be a floating-point value. The value is converted to the shortest possible decimal string using fixed or scientific format. The number of significant digits in the resulting string is given by the precision specifier in the format string梐 default precision of 15 is assumed if no precision specifier is present.Trailing zeros are removed from the resulting string, and a decimal point appears only if necessary. The resulting string uses fixed point format if the number of digits to the left of the decimal point in the value is less than or equal to the specified precision, and if the value is greater than or equal to 0.00001. Otherwise the resulting string uses scientific format.
    n Number. The argument must be a floating-point value. The value is converted to a string of the form "-d,ddd,ddd.ddd...". The "n" format corresponds to the "f" format, except that the resulting string contains thousand separators.
    m Money. The argument must be a floating-point value. The value is converted to a string that represents a currency amount. The conversion is controlled by the CurrencyString, CurrencyFormat, NegCurrFormat, ThousandSeparator, DecimalSeparator, and CurrencyDecimals global variables or their equivalent in a TFormatSettings data structure. If the format string contains a precision specifier, it overrides the value given by the CurrencyDecimals global variable or its TFormatSettings equivalent.
    p Pointer. The argument must be a pointer value. The value is converted to an 8 character string that represents the pointers value in hexadecimal.
    s String. The argument must be a character, a string, or a PChar value. The string or character is inserted in place of the format specifier. The precision specifier, if present in the format string, specifies the maximum length of the resulting string. If the argument is a string that is longer than this maximum, the string is truncated.
    x Hexadecimal. The argument must be an integer value. The value is converted to a string of hexadecimal digits. If the format string contains a precision specifier, it indicates that the resulting string must contain at least the specified number of digits; if the value has fewer digits, the resulting string is left-padded with zeros.
      

  4.   

    接上
    Format specifiers have the following form:"%" [index ":"] ["-"] [width] ["." prec] typeA format specifier begins with a % character. After the % come the following, in this order:An optional argument zero-offset index specifier (that is, the first item has index 0), [index ":"]
    An optional left justification indicator, ["-"]
    An optional width specifier, [width]
    An optional precision specifier, ["." prec]
    The conversion type character, typeThe following table summarizes the possible values for type:
      

  5.   

    ["." 摘要]这个说法有问题,最好说成[.,小数位数]好理解多了如果是小数位数的话,那么Format('x=%.5d', [12]); 的值是什么呢,能否具体把上面的例子给解释一下
      

  6.   

    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); //连接字符串忘了从那copy的了:-)   
    自己尝试一下