The variation of this function that can apply formatting can be used to convert numbers into a format required by another device, such as a robot or motion controller. For more information on formatting numbers, see the User-defined date/time and number formats section in Appendix A: Expression syntax.
If you need a string representation of an array, use the ARRAYTOSTRING function instead.
If you need to apply specific formatting to a timestamp, use the DATETIME function instead.
Specifies the value to be returned as string.
1. |
The following example returns a string representation of the fixture (for example, "Fixture(X=62.03, Y=59.90, Angle=50.202)").
TOSTRING(Flowcharts("BoardFinder").DefineWholeBoard.OutputFixture)
|
Specifies the value to be returned as string.
Specifies the format that the returned string should use.
The following are common formatting codes:
Value | Description |
"8:F2" |
Rounds the value to 2 decimal places, or
pads it with "0"s on the right. (more
details...)
|
":0000" |
Rounds the value to the nearest whole number and pads it to 4 digits with "0"s on the left. |
":%#" |
Multiplies the value by 100, rounds it to the nearest whole number, and appends the % sign before or after the number depending on where it appears in the formatting code. |
":%#.#" |
Multiplies the value by 100, rounds it to 1 decimal place and appends the % sign before or after the number depending on where it appears in the formatting code. |
":.00" |
Rounds the value to 2 decimal places, or pads it with "0"s on the left. |
":.##" |
Rounds the value to 2 decimal places. |
":F2" |
Rounds the value to 2 decimal places, or pads it with "0"s on the right. |
1. |
The following example returns 5 empty spaces, followed by "64.2700".
TOSTRING(64.27,"12:F4")
|
2. |
The following example returns "64.2700"
TOSTRING(64.27,"1:F4")
|
3. |
The following example returns "00006427"
TOSTRING(6427,":00000000")
|
4. |
The following example returns "64%"
TOSTRING(0.6427,":#%")
|