看见一个这样的 怪代码str(fps:7:4,s);str这个标示符没用过的delphi 帮助的解释
Formats a string and returns it to a variable.UnitSystemCategorystring handling routinesDelphi syntax:procedure Str(X [: Width [: Decimals ]]; var S);DescriptionIn Delphi code, Str converts X to a string representation according to the Width and Decimals formatting parameters. The effect is like a call to Write except the resulting string is stored in S instead of being written to a text file.X is an integer-type or real-type expression. Width and Decimals are integer-type expressions. S is a string-type variable or a zero-based character array variable if extended syntax is enabled.
Formats a string and returns it to a variable.UnitSystemCategorystring handling routinesDelphi syntax:procedure Str(X [: Width [: Decimals ]]; var S);DescriptionIn Delphi code, Str converts X to a string representation according to the Width and Decimals formatting parameters. The effect is like a call to Write except the resulting string is stored in S instead of being written to a text file.X is an integer-type or real-type expression. Width and Decimals are integer-type expressions. S is a string-type variable or a zero-based character array variable if extended syntax is enabled.
var
i: real;i := 12.456;
write(i:4:1); //输出i,宽度4位,小数1位
嗯,str函数现在都不用了,是向下兼容的。
谁知道Str 到底是做什么的 ?
这羊我啃不了
procedure Str(X [: Width [: Decimals ]]; var S); 过程应该是把X转换格式存到S中
Width指的是输出宽度,当X长度超出Width则自动突破,否则在前面加空格
如X=123那么Str(X:4,S);之后,S=" 123";
Decimals指的是小数的位数
如X=123.45678 那么Str(X:6:1,S);之后,S=" 123.4";
这样你就应该明白了
不过具体规则我记得不是很清楚,楼主可以自己测试一下就行了