CFile:Close CFile:Seek

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, ... )

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 fragment 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, Sprintf, global Printf, Wprintf