CFOG's PIP, December 1987, Volume 6 No. 2, Whole No. 62, page 7
Setting Input/Output Parameters with MODE.COM
by Bill Kuykendall
A number of callers on GFOG II inquired about a program called VSWITCH, referred to in the Kaypro 16 documents. VSWITCH is supposed to allow Kaypro 16 users to move between monochrome and color modes. Unfortunately, it appears that the VSWITCH program doesn't exist. What these callers need to learn about is MODE.COM -- one of the programs supplied with MS-DOS. Since MODE is not one of DOS's internal commands but rather, a separate program on the disk, you will need to make sure that it is available in a subdirectory that is included in the directory search path.
Now is as good a time as any to become familiar with your computer's DOS manual. There is generally a chapter with descriptions of each command listed alphabetically. The MODE command is one that it usually pays to check out because it is the one most often modified by computer manufacturers to provide extra features. As far as I know, however, all versions of MODE contain the basic set of functions provided by MicroSoft, unchanged. The commands for changing video modes, setting parameters for serial ports, and redirecting printer output are part of this basic set of instructions.
Video Modes
There may be modes other than those listed here available depending on the graphics adapter(s) provided with your machine:
40 CO40 80 CO80 BW40 MONO BW80
The syntax is MODE (argument). All of the above modes with the exception of the MONO option assume you are using a CGA (low resolution Color Graphics Adapter) video card. The MONO option selects an MDA (Monochrome Display Adapter) card if one is installed in the system.
From the description of the Kaypro 16 hardware provided in one of the messages I was fairly certain that the Kaypro 16 was using a GGA adapter only. If that was correct, the proper command for Monochrome operation would be MODE BW80 -- not MODE MONO. A bit of testing by a Kaypro 16 user determined that the Kaypro 16 has both CGA and MDA. The proper command is MODE MONO to specify a monochrome 80 column monitor. MODE BW80 specifies a GGA monitor with color disabled.
Setting Serial Communications Port Parameters
Serial ports are called COM1 or COM2 at the DOS level. You may have more COM ports than these 2, but only ports 1 and 2 are named devices in DOS versions up through at least 3.2. The only way to access a third or fourth COM port is through software packages such as ProComm which bypass DOS to access the ports directly.
Most modem programs and a few programs which support serial printers, plotters or other devices, allow you to specify the port setup, and take care of port initialization themselves. Many programs do not, however, and you may also wish to access the ports directly from DOS. You can, for example, print a file quickly from DOS by simply using the COPY command to COPY the file to the Serial port your laser printer is attached to:
COPY (filename) COM1:
To ensure that the port is initialized with the proper parameters prior to the first access you should place the following MODE command in your AUTOEXEC.BAT. The syntax is:
MODE COMx:baud[,parity,databits,stopbits,P]
Take note of the colon in this command. This is the only place where the colon is required. All other references to DOS devices may include the colon if desired but DOS does not require them.
Any of the values inside the brackets may be omitted if the defaults suit you, but if you choose to specify any of the optional parameters you must put in the appropriate number of commas to get the parameter in the right field. The default parameters are: E,7,1,- (even parity, seven databits, 1 stopbit, P option not selected). Don't worry, I'll get to that mysterious P option in a bit.
To set your first COM port up for an HP Laserjet printer you'd use this command:
MODE COM1:9600,n,8,1
or
MODE COM1:96,n,8,1
As you can see, you may also use just the first 2 digits of the baud rate if you prefer. Even though the hardware is capable of much higher rates of speed, MODE only recognizes the following baud rates: 110, 150, 300, 600, 1200, 2400, 4800, 9600. In practice this is not a problem because printers do not print faster than 9600 baud, and modem software usually provides its own rate selections.
If you experience timeout errors when you're printing something, add the [,P] option to your MODE command. This designates the port as a printer port and provides for continuous retries until the job is finished. CAUTION: Do NOT use the P option unless you know you need it. If you are printing from a program that does not pass control-break keypresses to DOS, you will have to reboot if there is an error. MODE also loads a memory resident kernel with this option that is notorious for causing hangups and crashes when certain other memory resident programs such as Sidekick are also loaded.
Redirecting Standard Printer Output to a COM Port
Parallel ports are named LPT#. DOS recognizes LPT1, LPT2, and LPT3. The actual DOS name for the logical Print Device is PRN. When DOS receives output destined for the PRN device it routes it to the first available parallel port usually LPT1.
Some programs such as WordStar and DOS's own PrintScreen function do not allow you to specify an output port. If your printer is attached to a parallel port this is no problem, because DOS will figure out which printer port is ready and send the output there. If your printer is attached to a serial port, however, you need to help DOS out a bit. The syntax is:
MODE LPT#=COMx
Normally, with only one printer you will want this to be LPT1=COMx. But suppose you have a parallel dot matrix printer on your desk and a serial connection to a shared laser printer that's located at your secretary's desk. By attaching the dot matrix to LPT1 and redirecting LPT2 to the serial printer port DOS can attend to your printing needs painlessly, without the need to reconfigure your software. Whenever the dot matrix printer is turned on it is the default for draft quality output. If you need laser quality, turn off your local printer. DOS will send the output to your secretary's printer automagically.