CFile:Printf


The Printf method writes formatted output to the file wrapped by this CFile object. This method provides functionality like the fprintf function in the C language.

Syntax

bResult = CFile:Printf( sFmt, ... )

bullet.gif    sFmt is a format string.

bullet.gif    ... refers to an optional variable argument list. (see Remarks)

bullet.gif    On success, this method returns true.

bullet.gif    On failure, this method returns false.

Remarks

Printf takes 1 or more arguments. The first argument is a string that may be either the value to print or a format to be used for interpreting any additional arguments. Additional arguments provide values for the % fields embedded in the format string. The syntax of this function is compatible with the fprintf function in C; for details about specifying the format string, refer to documentation for fprintf or printf in the C or C++ language.

Example

Suppose a CFile named F exists and the file is open for writing. The script below writes formatted text to the file using the Printf method:

s = "My string" ; n = 12.553

 

F:Printf("'%s': v=%-12lg\n", s, n/2.1 ))

-- do formatted print to the file

F:Flush()

-- make sure the data are in the file

Related Topics

CFile class, Sprintf, global Printf, Wprintf


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.