Sprintf

InstallShield 2016 » InstallScript Language Reference

The Sprintf function creates a string from variable data using format specifier and matching variables. Sprintf works like the Microsoft Windows API wsprintf.

Syntax

Sprintf ( svResult, szFormat [,arg] [,...] );

Parameters

Sprintf Parameters

Parameter

Description

svResult

Returns a string created from the arguments passed in the third and subsequent parameters and formatted according the specifications in the second parameter, szFormat.

szFormat

Specifies a string than can include literal text and must include one format specifier for each argument to be embedded in the string returned by svResult.

arg

You may specify up to nine arguments to be included in the message. You must have one argument for each format specifier in the message; the type of each argument must match the type of its respective format specifier.

Sprintf generates a compiler error or fail at run time under the following conditions:

More than nine format specifiers and arguments are specified. This results in a compiler error.
The number of arguments does not match the number of format specifiers. When a specifier does not have a corresponding argument, the resulting string contains unpredictable characters in the specifier's position. When there are more arguments than specifiers, the excess arguments are not inserted into the resulting string.
A variable does not match the type of its respective format specifier. The resulting string contains unpredictable characters in the specifier's position.

Return Values

If the Sprintf function is successful, the return value is the length—the number of characters—in the string stored in the variable svResult, not including the terminating null character.

See Also