Wprintf


The global Wprintf function writes formatted text in a specified text editor window. A reference to the text window is passed as the first function argument. This method provides functionality like the printf function in the C language. The WPrintf and Printf functions are different in using the Script Messages pane as stdout. The name of the present function means "window printf".

Syntax

bSuccess = Wprintf( CTextView, sFmt, ... )

where

    CTextView is a reference to an existing text window.

    sFmt is a format string.

    ... refers to an optional list of arguments.

    On success, this method returns true.

    On failure, this method returns false.

  

Wprintf takes 2 or more arguments. The first argument is a reference to a CTextView object that was created using the CreateTextWindow function or another function. The second 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. After the first argument, the syntax used by this function is compatible with the printf function in the C or C++ language.

Example

The script below uses Wprintf to write formatted text to a Mira Text Window named Script Messages:

T = CreateTextWindow("Window Name")

-- create a text output window

s = "My string" ; n = 12.553

-- values to print

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

-- do a formatted print to T

Related Topics

Printf

CTextView:Printf

CreateTextWindow

Sprintf