Format is a very common method, but it seems that I have tried some translators to help this method, let it have a complete profile for everyone to use:
First look at its statement:
Function Format (const format: string; constray of const): String; overload;
In fact, the Format method has two forms, and the other is three parameters. The main difference is that it is reasonable, but not much, so this is only the first introduction:
Function Format (const format: string; constray of const): String; overload;
The Format parameter is a format string for formatting the value in Args. What is args, it is a variant array, that is, there can be multiple parameters in it, and each parameter can be different.
As follows:
Format ('my name is% 6s', ['wind']);
After returning
My name is wind
Now let's see the details of the Format parameter:
You can write a normal string in Format, such as 'my name is'
But some format instruction characters have special significance, such as "% 6s"
The format instruction has the following form:
"%" [index ":"] ["-"] [width] ["". "PREC] TYPE
It starts with "%", and at the end of Type, Type represents a specific type. Middle is used
The formatted Type type instruction character is optional.
Let's take a look at Type, Type can be the following characters:
D 10 system, indicating a integer value
U and D are integer values, but it is no symbol, and if it corresponds to the value, it returns
It is a number of 32 times to reduce this absolute value.
Such as: Format ('this is% u', [- 2]);
Returns: this is 4294967294
F correspond to floating point numbers
I only need Format ('%. 2f', [floattostr (your (yourFloat)) to get two digits after the decimal point, and
e Science representation, corresponding to the number and floating point number,
For example, Format ('this is% e', [- 2.22]);
Returns: this is -2.22000000000000e 000
Wait a minute, if you narrow the accuracy of the number
g This can only correspond to floating point, and it will remove the number of excess in the value.
For example, Format ('this is% g', [02.200]);
Returns: this is 2.2
n can only be in the form of a floating point, and the value is converted to the number. Look at an example and understand
Format ('this is% n', [4552.2176]);
Returns this is 4,552.22
Note that there is two points, one is to expire two after the decimal, wait for how to eliminate this situation
Second, even if the decimal is not truncated, it will not be separated as an integer part.
M coin type, but there is a better format method for currency types, here is just simple formatting
In addition, it only corresponds to floating point values.
Format ('this IS% M', [9552.21]);
Returns: this is ¥ 9,552.21p corresponds to the pointer type, the return value is the address of the pointer, expressed in the form of hexadecimal.
E.g:
Var x: integer;
p: ^ integer;
Begin
X: = 99;
P: = @ x;
Edit1.text: = Format ('this is% p', [p]);
END;
The contents of Edit1 are: this is 0012F548
s correspond to the type of string, don't say more
X must be a shaped value, return in the form of hexadecimal
Edit1.text: = Format ('this is% x', [15]);
Return is: this is f
The type is described, and the instructions for formatting Type are described below:
[INDEX ":"] How to express this, look at an example
Format ('this IS% D% d', [12,13]);
The index of the first% D is 0, the second% D is 1, so when the character is displayed
This is this is IS 12 13
And if you define this:
Format ('this IS% 1: D% 0: D', [12, 13]);
Then the returned string becomes
THIS IS 13 12
I understand it now, INDEX in [Index ":"] indicates the parameter display in ARGS.
order
There is also a situation, if so Format ('% D% D% D% 0: D% d', [1, 2, 3, 4])
1 2 3 1 2 will be returned.
If you want to return 1 2 3 1 4, you must do this:
Format ('% D% D% D% 0: D% 3: D', [1, 2, 3, 4])
But when you use it, the index cannot exceed the number of ARGS, otherwise it will cause exceptions.
Such as Format ('this is% 2: D% 0: D', [12, 13]);
Due to only 12 13 in ARGS, INDEX can only be 0 or 1, here is 2 or wrong.
[width] Specifies the width of the value that will be formatted, seeing an example and understand
Format ('this is% 4d', [12]);
The output is: this is 12
This is relatively easy, but if the value of width is less than the length of the parameter, there is no effect.
Such as: Format ('this is% 1D', [12]);
The output is: this is 12
["-"] This specified parameter is one of the most, and [width] can be seen together:
Format ('this is% -4d, yes', [12]);
Output is: this is 12, YES
["." "prec] Specifies the precision, the best effects on floating point:
Format ('this is% .2f', [1.1234]);
Output this IS 1.12
Format ('this is%
.7f ', [1.1234]);
Lost this is 1.1234000
For integer, if PREC is small, there is no effect.
It is opposite to the number of bits of intersive value, will be completed in front of the whole value.
Format ('this is% .7d', [1234]);
Output is: this is 0001234]
For characters, just right, and integer values, if PREC is not effective if PREC is larger, it is not a result, which is smaller than the length of the string type, the character of the tail will be cut off.
Format ('this is% .2s', ['1234']);
Output is this IS 12
And this example said:
Format ('this is% e', [- 2.22]);
Returns: this is -2.22000000000000e 000
How to get extra 0, this is okay.
Format ('this is% .2e', [- 2.22]);
Ok, the first one is finished, it should be very familiar with his application.
///
Trimage of FormatorDateTime
His statement is:
Function Formator (const format: string; datetime: tdatetime): String;
OVERLOAD;
Of course, there is one of Format, but here only introduces the common first
The Format parameter is a formatted string. DateTime is a time type. Return value is a formatted string
Focus to see instruction characters in the format parameter
c Display time in a short time format, that is, all numbers
FormatorTime ('C', NOW);
Output is: 2004-8-7 9:55:40
D correspond to the date in the time, the date is a bit shows one bit, two digits display two digits
FormatorTime ('d', now);
Output may be 1 ~ 31
The meaning of DD and D, but it is always displayed in two digits
FormatorTime ('DD', NOW);
Output may be 01 ~ 31
DDD shows the day of the week
FormatorTime ('DDD', NOW);
Output is: Saturday
DDDD and DDD are the same.
But the above two may not be the same in other countries.
DDDDD Displays the Year Month Day in a short time format
FormatorTime ('DDDDD', NOW);
Output is: 2004-8-7
DDDDD shows the year and month in long-term format
FormatorTime ('DDDDDD', NOW);
The output is: August 7, 2004
E / EE / EEE / EEEE displays the year
FormatorTime ('EE', NOW);
The output is: 04 (indicating 04 years)
M / mm / mmm / mmmm means month
FormatorTime ('M', NOW);
Output is: 8
FormatorTime ('mm', now);
Output is 08
FormatorTime ('mmm', now);
Output is August
FormatorTime ('mmmm', now);
Output is August
Like DDD / DDDD, there may be different countries in other countries.
YY / YYYY means the year
FormatorTime ('yy', now);
Output is 04
Formator ('YYYY', NOW);
Output is 2004
H / hh, n / nn, s / s, z / zzz represents hours, minutes, seconds, milliseconds, respectively
T Display time in short time format
FormatorTime ('t', now);
Output is 10:17
Such as: formatdatetime ('YYYY', NOW) ' Formator (' M ', NOW) ' Moon ' FormatorTime (' DD ', NOW) ' Day ' ' FormatorTime ('DDD', NOW) '' formatdatetime ('t', now); return: ×××× year ×× month × day week × current day
TT display time in long-term format
FormatorTime ('TT', NOW);
Output is 10:18:46
Ampm displays morning or afternoon in a long time format
FormatDateTime ('TTAMPM', NOW);
The output is: 10: 22: 57 am
Probably, if you want to add a normal string in Format, you can use dual quotation marks to separate those specific characters, so if special characters are included in normal strings, it will not be displayed as time format:
FormatorTime ('"" Today IS "C', NOW);
Output is: Today IS 2004-8-7 10:26:58
"-" or "/" can be added to the date:
FormatDateTime ('"" Today IS "YY-MM-DD', NOW);
FormatorTime ('"" Today IS "YY / MM / DD', NOW);
Output is: Today IS
04-08-07
You can also use ":" to separate time
FormatorTime ('"Today IS" HH: NN: SS', NOW);
Output is: Today is 10:32:23
/
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22e 03Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
///
Trimage of FormatorDateTime
His statement is:
Function Formator (const format: string; datetime: tdatetime): String;
OVERLOAD;
Of course, there is one of Format, but here only introduces the common first
The Format parameter is a formatted string. DateTime is a time type. Return value is a formatted string
Focus to see instruction characters in the format parameter
c Display time in a short time format, that is, all numbers
FormatorTime ('C', NOW);
Output is: 2004-8-7 9:55:40
D correspond to the date in the time, the date is a bit shows one bit, two digits display two digits
FormatorTime ('d', now);
Output may be 1 ~ 31
The meaning of DD and D, but it is always displayed in two digits
FormatorTime ('DD', NOW);
Output may be 01 ~ 31
DDD shows the day of the week
FormatorTime ('DDD', NOW);
Output is: Saturday
DDDD and DDD are the same.
But the above two may not be the same in other countries.
DDDDD Displays the Year Month Day in a short time format
FormatorTime ('DDDDD', NOW);
Output is: 2004-8-7
DDDDD shows the year and month in long-term format
FormatorTime ('DDDDDD', NOW);
The output is: August 7, 2004
E / EE / EEE / EEEE displays the year
FormatorTime ('EE', NOW);
The output is: 04 (indicating 04 years)
M / mm / mmm / mmmm means month
FormatorTime ('M', NOW);
Output is: 8
FormatorTime ('mm', now);
Output is 08
FormatorTime ('mmm', now);
Output is August
FormatorTime ('mmmm', now); output is August
Like DDD / DDDD, there may be different countries in other countries.
YY / YYYY means the year
FormatorTime ('yy', now);
Output is 04
Formator ('YYYY', NOW);
Output is 2004
H / hh, n / nn, s / s, z / zzz represents hours, minutes, seconds, milliseconds, respectively
T Display time in short time format
FormatorTime ('t', now);
Output is 10:17
Such as: formatdatetime ('YYYY', NOW) ' Formator (' M ', NOW) ' Moon ' FormatorTime (' DD ', NOW) ' Day ' ' FormatorTime ('DDD', NOW) '' formatdatetime ('t', now);
Returns: ×××× year ×× month × × day × current day
TT display time in long-term format
FormatorTime ('TT', NOW);
Output is 10:18:46
Ampm displays morning or afternoon in a long time format
FormatDateTime ('TTAMPM', NOW);
The output is: 10: 22: 57 am
Probably, if you want to add a normal string in Format, you can use dual quotation marks to separate those specific characters, so if special characters are included in normal strings, it will not be displayed as time format:
FormatorTime ('"" Today IS "C', NOW);
Output is: Today IS 2004-8-7 10:26:58
"-" or "/" can be added to the date:
FormatDateTime ('"" Today IS "YY-MM-DD', NOW);
FormatorTime ('"" Today IS "YY / MM / DD', NOW);
Output is: Today IS
04-08-07
You can also use ":" to separate time
FormatorTime ('"Today IS" HH: NN: SS', NOW);
Output is: Today is 10:32:23
/
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
But if the fraction of 0 is less than the multiple of the Value, the corresponding decimal and bit numbers such as formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma. Formatfloat ('0,000.0', 22222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
The type is described, and the instructions for formatting Type are described below:
[INDEX ":"] How to express this, look at an example
Format ('this IS% D% d', [12,13]);
The index of the first% D is 0, the second% D is 1, so when the character is displayed
This is this is IS 12 13
And if you define this:
Format ('this IS% 1: D% 0: D', [12, 13]);
Then the returned string becomes
THIS IS 13 12
I understand it now, INDEX in [Index ":"] indicates the parameter display in ARGS.
order
There is also a situation, if so Format ('% D% D% D% 0: D% d', [1, 2, 3, 4])
1 2 3 1 2 will be returned.
If you want to return 1 2 3 1 4, you must do this:
Format ('% D% D% D% 0: D% 3: D', [1, 2, 3, 4])
But when you use it, the index cannot exceed the number of ARGS, otherwise it will cause exceptions.
Such as Format ('this is% 2: D% 0: D', [12, 13]);
Due to only 12 13 in ARGS, INDEX can only be 0 or 1, here is 2 or wrong.
[width] Specifies the width of the value that will be formatted, seeing an example and understand
Format ('this is% 4D', [12]); output is: this is 12
This is relatively easy, but if the value of width is less than the length of the parameter, there is no effect.
Such as: Format ('this is% 1D', [12]);
The output is: this is 12
["-"] This specified parameter is one of the most, and [width] can be seen together:
Format ('this is% -4d, yes', [12]);
Output is: this is 12, YES
["." "prec] Specifies the precision, the best effects on floating point:
Format ('this is% .2f', [1.1234]);
Output this IS 1.12
Format ('this is%
.7f ', [1.1234]);
Lost this is 1.1234000
For integer, if PREC is small, there is no effect.
It is opposite to the number of bits of intersive value, will be completed in front of the whole value.
Format ('this is% .7d', [1234]);
Output is: this is 0001234]
For characters, just opposite the integer, if prec is larger than the length of the string type
There is no effect, but it is much smaller than the length of the string type, it will cut off the character.
Format ('this is% .2s', ['1234']);
Output is this IS 12
And this example said:
Format ('this is% e', [- 2.22]);
Returns: this is -2.22000000000000e 000
How to get extra 0, this is okay.
Format ('this is% .2e', [- 2.22]);
Ok, the first one is finished, it should be very familiar with his application.
///
Trimage of FormatorDateTime
His statement is:
Function Formator (const format: string; datetime: tdatetime): String;
OVERLOAD;
Of course, there is one of Format, but here only introduces the common first
The Format parameter is a formatted string. DateTime is a time type. Return value is a formatted string
Focus to see instruction characters in the format parameter
c Display time in a short time format, that is, all numbers
FormatorTime ('C', NOW);
Output is: 2004-8-7 9:55:40
D correspond to the date in the time, the date is a bit shows one bit, two digits display two digits
FormatorTime ('d', now);
Output may be 1 ~ 31
The meaning of DD and D, but it is always displayed in two digits
FormatorTime ('DD', NOW);
Output may be 01 ~ 31
DDD shows the day of the week
FormatorTime ('DDD', NOW);
Output is: Saturday
DDDD and DDD are the same.
But the above two may not be the same in other countries.
DDDDD Displays the Year Month Day in a short time format
FormatorTime ('DDDDD', NOW);
Output is: 2004-8-7
DDDDD shows the year and month in long-term format
FormatorTime ('DDDDDD', NOW);
The output is: August 7, 2004 E / EE / EEE / EEEE shows the year
FormatorTime ('EE', NOW);
The output is: 04 (indicating 04 years)
M / mm / mmm / mmmm means month
FormatorTime ('M', NOW);
Output is: 8
FormatorTime ('mm', now);
Output is 08
FormatorTime ('mmm', now);
Output is August
FormatorTime ('mmmm', now);
Output is August
Like DDD / DDDD, there may be different countries in other countries.
YY / YYYY means the year
FormatorTime ('yy', now);
Output is 04
Formator ('YYYY', NOW);
Output is 2004
H / hh, n / nn, s / s, z / zzz represents hours, minutes, seconds, milliseconds, respectively
T Display time in short time format
FormatorTime ('t', now);
Output is 10:17
Such as: formatdatetime ('YYYY', NOW) ' Formator (' M ', NOW) ' Moon ' FormatorTime (' DD ', NOW) ' Day ' ' FormatorTime ('DDD', NOW) '' formatdatetime ('t', now);
Returns: ×××× year ×× month × × day × current day
TT display time in long-term format
FormatorTime ('TT', NOW);
Output is 10:18:46
Ampm displays morning or afternoon in a long time format
FormatDateTime ('TTAMPM', NOW);
The output is: 10: 22: 57 am
Probably, if you want to add a normal string in Format, you can use dual quotation marks to separate those specific characters, so if special characters are included in normal strings, it will not be displayed as time format:
FormatorTime ('"" Today IS "C', NOW);
Output is: Today IS 2004-8-7 10:26:58
"-" or "/" can be added to the date:
FormatDateTime ('"" Today IS "YY-MM-DD', NOW);
FormatorTime ('"" Today IS "YY / MM / DD', NOW);
Output is: Today IS
04-08-07
You can also use ":" to separate time
FormatorTime ('"Today IS" HH: NN: SS', NOW);
Output is: Today is 10:32:23
/
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range. The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: Formatfloat ('000.000', 22.22); output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
///
Trimage of FormatorDateTime
His statement is:
Function Formator (const format: string; datetime: tdatetime): String;
OVERLOAD;
Of course, there is one of Format, but here only introduces the common first
The Format parameter is a formatted string. DateTime is a time type. Return value is a formatted string
Focus to see instruction characters in the format parameter
c Display time in a short time format, that is, all numbers
FormatorTime ('C', NOW);
Output is: 2004-8-7 9:55:40
D correspond to the date in the time, the date is a bit shows one bit, two digits display two digits
FormatorTime ('d', now);
The output may be the same as 1 ~ 31DD and D, but it is always displayed in two digits.
FormatorTime ('DD', NOW);
Output may be 01 ~ 31
DDD shows the day of the week
FormatorTime ('DDD', NOW);
Output is: Saturday
DDDD and DDD are the same.
But the above two may not be the same in other countries.
DDDDD Displays the Year Month Day in a short time format
FormatorTime ('DDDDD', NOW);
Output is: 2004-8-7
DDDDD shows the year and month in long-term format
FormatorTime ('DDDDDD', NOW);
The output is: August 7, 2004
E / EE / EEE / EEEE displays the year
FormatorTime ('EE', NOW);
The output is: 04 (indicating 04 years)
M / mm / mmm / mmmm means month
FormatorTime ('M', NOW);
Output is: 8
FormatorTime ('mm', now);
Output is 08
FormatorTime ('mmm', now);
Output is August
FormatorTime ('mmmm', now);
Output is August
Like DDD / DDDD, there may be different countries in other countries.
YY / YYYY means the year
FormatorTime ('yy', now);
Output is 04
Formator ('YYYY', NOW);
Output is 2004
H / hh, n / nn, s / s, z / zzz represents hours, minutes, seconds, milliseconds, respectively
T Display time in short time format
FormatorTime ('t', now);
Output is 10:17
Such as: formatdatetime ('YYYY', NOW) ' Formator (' M ', NOW) ' Moon ' FormatorTime (' DD ', NOW) ' Day ' ' FormatorTime ('DDD', NOW) '' formatdatetime ('t', now);
Returns: ×××× year ×× month × × day × current day
TT display time in long-term format
FormatorTime ('TT', NOW);
Output is 10:18:46
Ampm displays morning or afternoon in a long time format
FormatDateTime ('TTAMPM', NOW);
The output is: 10: 22: 57 am
Probably, if you want to add a normal string in Format, you can use dual quotation marks to separate those specific characters, so if special characters are included in normal strings, it will not be displayed as time format:
FormatorTime ('"" Today IS "C', NOW);
Output is: Today IS 2004-8-7 10:26:58
"-" or "/" can be added to the date:
FormatDateTime ('"" Today IS "YY-MM-DD', NOW);
FormatorTime ('"" Today IS "YY / MM / DD', NOW);
Output is: Today IS
04-08-07
You can also use ":" to separate time
FormatorTime ('"Today IS" HH: NN: SS', NOW);
Output is: Today is 10:32:23
/
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Three. Usage of formatfloat
Common statement:
Function formatfloat (const format: string; value: extended): String; overload;
And the same format parameter is formatted in the format command character, value is extended type
Why is this type because it is the largest representation in all floating point values. If you pass the parameters of the method, such as Double or others, you can save not exceeding the range.
The key is to see the usage of format parameters
0 This command specifies the corresponding number of bits.
For example: FormatFloat ('000.000', 22.22);
The output is 022.220
Pay attention to it, if the number of 0 of the integer part is less than the number of integers in the value of the value parameter, there is no effect.
Such as: Formatfloat ('0.00', 22.22);
Output: 22.22
However, if the fraction of 0 is smaller than the multiple of the Value, the corresponding decimal and bit number will be cut off.
Such as: formatfloat ('0.0', 22.22);
Output: 22.2
You can also specify a comma in an integer 0. This integer number must be greater than 3, and there will be a comma.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.
Formatfloat ('0,000.0', 2222.22);
The output is: 2, 222.2
If so formatfloat ('000, 0.0', 2222.22);
Its output is: 2,222.2
Note that its law # and 0 usage are the same, I haven't measured what is different.
Formatfloat ('##. ##', 22.22);
The output is: 22.00
E science stories, seeing a few examples probably understand
Formatfloat ('0.00e 00', 2222.22);
The output is 2.22E 03
Formatfloat ('0000.00E 00', 2222.22);
The output is 2222.22e 00
Formatfloat ('00 .0e 0 ', 2222.22);
22.2e 2
Understand, all over the right of E right.
This method is not difficult, probably this is like this.