MATLAB COMPILER RELEASE NOTES Guía de usuario Pagina 162

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 264
  • Tabla de contenidos
  • SOLUCIÓN DE PROBLEMAS
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 161
5 Controlling Code Generation
5-46
The print handler that you write must:
Take a single argument of type
const char * that points to the t ext to be
displayed.
Return
void.
The print handler routine
WinPrint in the example program illustrates one
possible approach to writing a print handler for a Windows program.
When the example
WinMain routine prints the array returned by mlfMrank,
mlfPrintMatrix(R);
the registered print handler, WinPrint, is called. If array R contains a 12-row
result from the call to
mlfMrank, the application calls WinPrint 12 times, each
time passing the next line of data. The print handler
WinPrint dynamically
allocates a buffer to hold the printable contents of array
R and appends e ach
text string passed to it to the buffer.
In this design, the print handler prints to a buffer rather than the screen. A
companion function
WinFlush actually displays the 12 lines of data in a
Windows message box.
In the example,
WinMain calls WinFlush immediately following the call to
mlfPrintMatrix.
mlfPrintMatrix(R);
WinFlush();
Though WinFlush is not part of t he print handler, this implementation of a
print handler requires that you call
WinFlush after any mlf function that
causes a series of calls to the print handler. For this short program, this design
is appropriate.
Here is the source code from
mrankwin.c for WinPrint and WinFlush.It
includes:
The static, global variables used by the two routines
static int totalcnt = 0;
static int upperlim = 0;
static int firsttime = 1;
char *OutputBuffer;
Vista de pagina 161
1 2 ... 157 158 159 160 161 162 163 164 165 166 167 ... 263 264

Comentarios a estos manuales

Sin comentarios