PWB Extension Converts Selected Text to Uppercase LettersLast reviewed: July 17, 1997Article ID: Q94837 |
1.00 1.10 2.00 | 1.00 1.10
MS-DOS | OS/2kbtool kbcode The information in this article applies to:
SUMMARYThe text below demonstrates the process to create a Programmer's WorkBench (PWB) extension to convert one selected line of text to uppercase. Note that nothing appears to happen if the cursor is on a different line than the selected line.
MORE INFORMATIONTo load and use the extension, perform the following five steps:
Sample Code
/* * Compile options needed: cl /c /Gs /ACw reverse.c * link exthdr test, reverse.mxt; */ #define BUF_LEN 250 #define TRUE 1 #define FALSE 0 #include <ext.h> #include <string.h> #include <ctype.h>PWBFUNC ToUpper(unsigned argData, ARG _far *pArg, flagType fMeta); struct swiDesc swiTable[] = { {"ToUpper", toPIF(ToUpper), SWI_BOOLEAN},
{ NULL, NULL, 0}
};
struct cmdDesc cmdTable[] = { {"ToUpper", ToUpper, 0, STREAMARG},
{NULL, NULL, 0, 0}
};
void EXTERNAL WhenLoaded(void){ int hmatch;
hmatch = AddMenu("~Case", "xxxx", "", TRUE);
AddMenuItem(hmatch, "~Lower to Upper", "Case switch", NULL, "ToUpper");
}
PWBFUNC ToUpper(unsigned argData, ARG _far *pArg, flagType fMeta) { LINE ycurr, ystart, yend;
COL xcurr, xstart, xend;
char buf[BUF_LEN + 1];
PFILE pfile;
int i;
int maxlines;
switch (pArg->argType)
{
case STREAMARG:
// The following code retrieves the corners
// of the stream for future use
ystart = pArg->arg.streamarg.yStart;
yend = pArg->arg.streamarg.yEnd;
xstart = pArg->arg.streamarg.xStart;
xend = pArg->arg.streamarg.xEnd;
pfile = FileNameToHandle("", "");
maxlines = FileLength(pfile);
ycurr = ystart;
xcurr = xstart;
// Read the argument
pfile = FileNameToHandle("","");
GetLine(ystart, buf, pfile);
// Convert to uppercase letters
for ( ; xcurr < xend ; xcurr++)
buf[xcurr] = toupper(buf[xcurr]);
// Output converted argument
PutLine(ystart, buf, pfile);
break;
default:
DoMessageBox("Default", buf, NULL, MBOX_OK, 0);
break;
}
}
|
Additional reference words: kbinf 1.00 1.10 2.00 PWBIss
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |