PrintFormat
Print the values of one or more expressions to the script console pane, using a format string.
void PrintFormat(string format, ...)
If a print file has been opened, additionally writes those values to the print file.
This is useful when:
- There are a number of arguments and or text to intersperse with those arguments
- When specific formatting of values is needed. e.g. only two decimal points (2d.p.) or with zeros in front.
PrintFormat("The X, Y Z values of point01 are {0}, {1}, {2}", point01.X, point01.Y, point01.Z); PrintFormat("{0}\\{1}{2:D4}", stringFilePath, stringFileName, num);
The values in brackets list correspond to the number of arguments on the right. The first one is {0}, the second is {1}, the third {2} etc. The user can specify as many as need be. Formatting can also be applied to these values see below:
Special Characters:
\n New line \r Carriage return \t tab \\ back slash \" Quotes
Formatting Values
C Currency PrintFormat("{0:C3}", 1.2345) // $1.234 F Fixed Point PrintFormat("{0:F3}", 1.2345) // 1.234
(Specifies max. decimal places—fills with zeros necessary)
G General or Scientific PrintFormat("{0:G3}", 1.2345) // 1.23 D Decimal PrintFormat("{0:D4}", 12) // 0012
(Used for whole numbers. How many digits. Extras filled with zeros before number. Useful for creating file numbers like 001, 002 for .jpg's or such like)
E or e Exponent PrintFormat("{0:E3}", 12) // 1.27E-001
also useful are:
0 Zero Placeholder X # Digit placeholder . Decimal Point , Group Separator or multiplier % Percent Notation 'x' Literal String quote \ Literal Character quote ; Section separator E0, E+0, E-0, e0, e+0, e-0 Exponent Notation
Custom Formats:
Formatting values can be used for custom formats
Pound Sterling PrintFormat('{0:'£'00.00}', 0.127); // £00.13 percent PrintFormat("{0:#%}", 0.127) // 13% PrintFormat("{0:00.00%}", 0.127) // 12.7%
Display values differently according to values
percent PrintFormat('{0:#.##;(#.##);0.00}', 0.127); // .13 PrintFormat('{0:#.##;(#.##);0.00}', -0.127); // (.13) PrintFormat('{0:#.##;(#.##);0.00}', 0.00); // 0.00