Sprintf
The global Sprintf function formats text to a string and returns the string to the script. This provides functionality similar to the sprintf function in the C language.
sString = Sprintf( sFmt, ... ) |
sFmt is a format string.
... refers to an optional variable argument list (see Remarks).
sString is the returned format string. It may be passed directly to a printing function.
On success, this function returns true.
On failure, this function returns false.
Sprintf takes 1 or more arguments. The first argument is a format string and is required. Additional arguments specify expressions needed by the fields embedded in the format string. This function is similar to the sprintf function in C (for details about using the format string, refer to documentation for sprintf in the C or C++ language). The difference between these two implementations is that the C sprintf function takes the target string as its first argument. In contrast, the present function returns a string but does not use it as an argument.
Often it is desirable to use Sprintf directly without storing the returned string. To do this, specify it as the argument of a function like Printf or CFile:Printf in the following way:
This is equivalent to the following 2-line procedure:
You can also use the format string to explicitly create embedded formats using the%% construct to realize a % sign in the returned string. For example,
produces a format string result: fmt = %-16.16s
The script below formats 2 values to a string and then prints the result to the Script Messages window:
|
-- values to format |
|
-- format the string |
|
-- print the string |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics,
Inc. All Rights Reserved.