WINCMD: a Windows Command Language
Total Page:16
File Type:pdf, Size:1020Kb
UTILITIES WINCMD: A Windows Command Language BY DOUGLAS BOLING emember the DOS batch USING WINCMD Before discussing how WCM, the WINCMD default exten i files with which you once to us_e WINCMD, I must start with some in the edit box. In the Combo Box t proudly automated all your terminology. WI CMD.EXE is the Win lists the programs, enter the path to - routine tasks? If you've dows program I've written. It interprets filename of WINCMD.EXE. Click joined the mad rush to Win programs-which are ASCII files-that the OK button and you're set! dows, you've simply had to are written in the WINCMD language. From now on, any time you click learn to do without this use To keep the two kinds of programs sepa a WINCMD file in the File Manager ful and convenient facility. rate, I'll use the full name and extension, Program Manager, Windows will am The DOS batch file lan WINCMD.EXE, when referring to the matically start WINCMD.EXE and p guage may have been limited, but Win utility itself. I'll refer to the ASCII files it the name of your WINCMD progra dows supported nothing at all in its that WINCMD.EXE interprets as When WINCMD.EXE is started with ~ place- until now. WINCMD programs. filename on the command line, it will im WINCMD.EXE, this issue's free util To install WINCMD.EXE, just copy mediately start executing that file. Whe ity, is a Windows-based command file in it, along with WINCMD.ICO (its icon WINCMD.EXE has finished executin" terpreter that lets you create simple Win file) and any .WCM files you have (two the WINCMD program, it will gracefull_ dows programs that perform the terminate. repetitive functions that were once the WNDCMD.EXE, a Since debugging is important even f domain of DOS batch files. WINCMD WINCMD programs, WINCMD.E goes far beyond the simple DOS batch Windows counterpart to provides help m this area. L file language, however. Its language in WI CMD.EXE is started with an l cludes looping and branching statements DOS's hatch language, lets command switch before the WINC along with user-defined subroutines and program name, WINCMD.EXE will di functions. Both numeric and string vari you automate tasks in the play a window with your WINCMD pro ables are supported, as is a full suite of gram loaded into memory, ready to ex - arithmetic and logical operators. environment and even goes cute. Be sure not to place the /L after th You can use any ASCII editor, such WI CMD program name, or it will as Notepad, to create WINCMD pro beyond its ancestor's considered an argument to the comman grams. Typically, these programs will file. When WINCMD.EXE starts, it per carry a .WCM extension, though this is capabilities. forms some preprocessing on your not required unless you want the pro WINCMD program. If it finds any line gram to be callable from another it does not understand, you'll get appro WINCMD program. A single .WCM file are supplied with the program), into a di priate print error messages with Jin can be up to 64K in size, though its exe rectory on your path. Select the File I numbers to help you find the problem. cutable parts (those not made up of com New menu item in the Program Manager Error messages are displayed for such ment lines) are limited to about 45K. and choose Program Item. Enter the faults as lines being too long or numbers Both the WINCMD program and its short title you want to appear under the too big. When an error message i5 C source files can be downloaded from icon as the Description, and enter the printed, WINCMD.EXE changes to di_ PC MagNet as WINCMD.ZIP. See the complete path and WINCMD.EXE on play two windows. The listing windo " Utilities by Modem" sidebar for instruc the command line. displays the WINCMD program with th tions. You can also get the files by send To make it easy to run WINCMD pro line highlighted that is to be execut ing a postcard with your name, address, grams, you should then also use the File next. The output window displays the las and disk size preference (360K, 720K, Manager to associate the .WCM file ex 100 lines printed by the WINCMD pr 1.2MB, or 1.44M) to the attention of tension with WI CMD.EXE. To do this, gram as well as the error messages. Katherine West, PC Magazine, One Park start the Windows File Manager and se WINCMD.EXE allows you to run Ave., ew York, NY 10016-5802. No lect the File I Associate menu item. WINCMD program from the window · phone calls, please! When the dialog box appears enter two different ways. The program can • 302 PC MAGAZINE APRIL 27, 1993 U'!'ILITIES button will cause WINCMD.EXE to exe WI NCM D Statements and Functions cute one line of the WINCMD program. Statement Description The listing window will highlight the next IF{expression} Branching statement line to be executed. [THEN] WINCMD VARIABLES AND ARITHMETIC {statement} The WINCMD syntax combines the [ELSE] power of a high-level language with the {statement}] simple command line operation of a DO Block statement batch language. Before discussing the dif {statement} ferent WINCMD statements in detail, I {statement} should explain how WINCMD programs use variables. The WINCMD language makes no distinction between string vari ables and numeric variables. That is, a {statement}END variable that has been assigned a string WHILE {condition} Loop statement value can later be assigned a number and {statement} vice versa. Variables do not have to be EXIT [return code] Terminates a WINCMD program declared before they are used. As you RETURN [return code] Terminates a subroutine would expect, variables are assigned LEAVE Exits from a loop using the equal sign. PRINT {expression} Displays a line of text to the user The following three statements are ex SAY {expression} Displays a line of text to the user amples of valid WINCMD assignments. REM {text} Comment, remainder of text on the line ignored // {text} Comment, remainder of text on the line ignored var= 1 • {text} Comment, remainder of text on the line ignored var= magazine var= "I like PC Magazine" Function Description LENGTH(string) Returns the length of a string . In the first assignment above, the vari UCASE(string) Returns a copy of the string in upper case characters. able VAR is given the value 1. The sec SUBSTR(string, start, length) Returns a part of a string. ond assignment has the variable assigned ARG(number) Returns an argument to program or a subroutine. the string " magazine." In the third as DELAY(number) Halts program execution for a number of milliseconds. signment, VAR is assigned the string " I APPACTIVATE(win title text) Activates the window with the matching title text. like PC Magazine." The quotes allow GETAPPACTIVE (no parameters) Returns the title text of the currently active window. spaces to be included in the string as GETAPPEXE(win title text) Returns the EXE file name for a window. signed to VAR. If the quotes were not SENDKEYS(send key string) Sends a series of keys to the active application. used, WINCMD would attempt to assign MSGBOX(message, title, flags) Displays a message box. the variable VAR with the string " I" , but ASKBOX(text, default answer) Displays a dialog box so that the user can enter a value . would then find the additional characters TICKS(no parameters) Returns the number of milliseconds since Windows was on the line. WINCMD would then stop started. execution and print the error message Figure 1: These statements and functions are supported in the WINCMD language. "Extra characters on line. " Variable names may contain numbers, run normally either by pressi ng the Run ton. If you want to start the program from letters. or the characters _, $, % , and #, button or by selecting the Run I Run Pro the beginning. first click on the Reset but but the first character in a variable must gram menu selection. The WIN ton to reset the program and then hit the always be either a letter or underscore CMD.EXE window will then change to Run button to start the program on its (_). Variable names are not case-sensi display only the output window and run way. Note that when WINCMD resets a tive; the names BOB, Bob, and bob all the WINCMD program. The Run button program, it rereads the program from the refer to the same variable. Variable text will change to Stop. disk. This means that you can make names can be up to 253 characters long. Pressing the Stop button will cause changes to the program and then you can Variables can be used anywhere strings WINCMD.EXE to stop executing the have WINCMD load those changes by or numbers can be used in the program. INCMD program and to display both pressing the Reset button. The numbers you use may range from .he output and listing, windows. Again, The other way to run a WINCMD pro -2,147,483,648 to 2,147,483,647, and can the line in the program that wou\d have gram is 'oy stepping, through i.t one \i.ne be expressed in binary, octal, decimal, or been executed next is highlighted. The at a time. Single stepping is very handy hexadecimal format. (ln entering num program can then be restarted from this to see exactly how a WINCMD program bers, do not type in the commas shown point simply by clicking on the Run but- is being executed.