Print Handlers
5-47
•The print handler routine itself that deposits the text passed to it in an
output buffer
void WinPrint( char *text)
{
int cnt;
/* Allocate a buffer for the output */
if (firsttime) {
OutputBuffer = (char *)mxCalloc(1028, 1);
upperlim += 1028;
firsttime = 0;
}
/* Make sure there’s enough room in the buffer */
cnt = strlen(text);
while (totalcnt + cnt >= upperlim) {
char *TmpOut;
upperlim += 1028;
TmpOut = (char *)mxRealloc(OutputBuffer, upperlim);
if (TmpOut != NULL)
OutputBuffer = TmpOut;
}
/* Concatenate the next line of text */
strncat(OutputBuffer, text, cnt);
/* Update the number of characters stored in the buffer */
totalcnt += cnt;
}
•The related function WinFlush that actually displays the text from the
output buffer in a Windows message box.
void WinFlush(void)
{
MessageBox(NULL, OutputBuffer, "MRANK", MB_OK);
mxFree(OutputBuffer);
}
For more details on mlfPrintMatrix,seetheMATLAB C Math Library User’s
Guide.
Comments to this Manuals