Siebel eScript Language Reference > Siebel eScript Commands > The Clib Object String Methods >

Clib.sprintf() Method


This method writes output to a string variable according to a prescribed format.

Syntax

Clib.sprintf(stringVar, formatString, var1, var2, ..., varn)

Parameter
Description

stringVar

The string variable to which the output is assigned

formatString

A string indicating how variable or literal parameters are to be treated

var1, var2, ..., varn

Variables to be formatted using the formatString

Returns

The number of characters written into buffer if successful; otherwise, EOF.

Usage

This method formats the values in the variables according to formatString and assigns the result to stringVar. The formatString contains character combinations indicating how following parameters are to be treated. For information on format strings used with Clib.sprintf(), see Table 3 in the section Clib.asctime() Method. The string value need not be previously defined; it is created large enough to hold the result. Characters are printed as read to standard output until a percent character (%) is reached. The percent character indicates that a value is to be printed from the parameters following the format string.

Example

Each of the following lines shows an sprintf example followed by the resulting string:

var testString;
Clib.sprintf(testString, "I count: %d %d %d.",1,2,3)
//"I count: 1 2 3"
var  a = 1;
var  b = 2;
Clib.sprintf(testString, "%d %d %d",a, b, a+b)       //"1 2 3"

See Also

Clib.rsprintf() Method

Siebel eScript Language Reference