Microsoft KB Archive/94837

= PWB Extension Converts Selected Text to Uppercase Letters =

Article ID: 94837

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft Programmer's Workbench for MS-DOS 1.0
 * Microsoft Programmer's Workbench for MS-DOS 1.1
 * Microsoft Programmer's Workbench for MS-DOS 2.0
 * Microsoft Programmer's Workbench for OS/2 1.0
 * Microsoft Programmer's Workbench for OS/2 1.1

-



This article was previously published under Q94837



SUMMARY
The 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 INFORMATION
To load and use the extension, perform the following five steps:  Copy REVERSE.MXT into the same directory as PWB. By default on an MS-DOS system, this is the BIN subdirectory. By default on an OS/2 system, this is the BINP subdirectory. Modify the TOOLS.INI file to place a load command in the [PWB] section. For example,

[pwb]

load:[path\]reverse

 Start the PWB editor. Select the text to convert to uppercase letters. The selection must be on one line. From the Case menu, select Lower to Upper.

The source code for this PWB extension is as follows.

Sample Code
/* * Compile options needed: cl /c /Gs /ACw reverse.c *                          link exthdr test, reverse.mxt; */


 * 1) define BUF_LEN  250
 * 2) define TRUE     1
 * 3) define FALSE    0


 * 1) include 
 * 2) include <string.h>
 * 3) include <ctype.h>

PWBFUNC ToUpper(unsigned argData, ARG _far *pArg, flagType fMeta); struct swiDesc swiTable[] = {  {&quot;ToUpper&quot;, toPIF(ToUpper), SWI_BOOLEAN}, { NULL, NULL, 0} };

struct cmdDesc cmdTable[] = {  {&quot;ToUpper&quot;, ToUpper, 0, STREAMARG}, {NULL, NULL, 0, 0} };

void EXTERNAL WhenLoaded(void) {  int hmatch; hmatch = AddMenu(&quot;~Case&quot;, &quot;xxxx&quot;, &quot;&quot;, TRUE); AddMenuItem(hmatch, &quot;~Lower to Upper&quot;, &quot;Case switch&quot;, NULL, &quot;ToUpper&quot;); }

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(&quot;&quot;, &quot;&quot;); maxlines = FileLength(pfile); ycurr = ystart; xcurr = xstart;

// Read the argument pfile = FileNameToHandle(&quot;&quot;,&quot;&quot;); 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(&quot;Default&quot;, buf, NULL, MBOX_OK, 0); break; } }

Additional query words: kbinf 1.00 1.10 2.00 PWBIss

Keywords: kb16bitonly KB94837

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.