# $str.printf

Returns a formatted string in a C sprintf-like fashion.

Usage

    $str.printf(<format>[,<parameter>[...]]);

Description

This function acts like the C sprintf(): it returns a string formatted by following the specification in <format> and by using the following corresponding variadic parameters. Since the percent sign is used as variable prefix in KVIrc, this function uses the question mark '?' instead.
The <format> string can contain the following escape sequences:

?s | The next parameter is evaluated as a string and substituted in place of ?s
?d | The next parameter is evaluated as a signed integer and substituted in place of ?d
?i | Same as ?d
?u | The next parameter is evaluated as an unsigned signed integer and substituted in place of ?d
?x | The next parameter is evaluated as an unsigned integer and its hexadecimal representation is substituted in place of ?x
?h | Same as ?x
?X | Same as ?x but toUppercase hexadecimal digits are used
?H | Same as ?X
?? | A literal question mark
?[.N]f | The next parameter is evaluated as a real floating point value and its representation substituted in place of ?f. The optional [.N] modifier, where N is an unsigned integer, represents the desired precision.
?[.N]e | The next parameter is evaluated as a real floating point value and its scientific representation substituted in place of ?e. The optional [.N] modifier, where N is an unsigned integer, represents the desired precision.
?[.N]E | Same as ?e but an toUppercase E is used as the exponent prefix

Syntax Specification

    <string> $str.printf(<format:string>[,<parameter:variant>[...]]);

Examples

        %val = $(1.0 / 3.0);
        $str.printf("1/3 with a precision of 3 digits is ?.3f, while in scientific notation it's ?e",%val,%val)

Index, Functions

KVIrc 4.2.0.6190 Documentation
Generated by portbuild at Mon Aug 12 12:09:14 2013