String.Format |
Top Previous Next |
Syntax function String.Format(FormatStr: string; val1: variant [; val2: variant; valn: variant; ...]): string
Alternative Names
Description Returns a formatted string with the given values formatted as per FormatStr. The values are listed separately, using val1 and so on.
The formatting string can include regular text and format specifiers. Format specifiers are in the form of: "%" [index ":"] ["-"] [width] ["." prec] type
A format specifier begins with a % character, optionally followed by additional formatting options, followed by a type specifier.
The decimal separator and thousand separator are taken from the Control Panel and can be modified using Util.SetSystemText.
See Also
Example execute udsblock as begin /* this formatstr includes literal text and then lists all values */ valueout = String.Format('These are the values: %d %d %u %s', 5, -10, 10, 'test'); GUI.ShowMessage(valueout);
/* this formatstr formats a floating point value followed by a text */ valueout = String.Format('%.2f %s', 5.10, 'test'); GUI.ShowMessage(valueout);
/* this formatstr outputs the given argument 3 times by using the index specifier to indicate the first argument for the 2nd and 3rd format specifier */ valueout = String.Format('%s %0:s %0:s', 'test'); GUI.Showmessage(valueout); end |