Contents of the BD.DOC file
BACKDOWN.EXE (Version 1.0)
Bob Flanders and Michael Holmes May 12, 1992 (Utilities)
BACKDOWN: A TSR (terminate-and-stay-resident) utility, BACKDOWN lets you
start and manage communications sessions and file downloads in the
background while you continue working in your foreground application.
You can run BACKDOWN interactively, or you can use its script facilities
to automate all or part of its operations.
Specifically, BACKDOWN provides five major functions:
a "dumb terminal" interface, script execution, a script compiler,
protocol-based download capability, and background execution. The program
requires DOS 3.1 or later and occupies about 16K when resident in memory.
A complete set of source code files are available in case you wish
to study or customize them. They are included in BD.ZIP or listed as
BDSRC.ZIP. The source can be assembled with Microsoft MASM 5.1 or 6.0 or
Borland's Turbo Assembler 2.5 or 3.0. (Other assemblers may work, but
we have tested it only using these.) Using the Microsoft assembler, you
create BD.EXE from its .ASM source with the two commands
The statements needed to assemble the BACKDOWN downloading protocol
files are as follows:
EXE2BIN BXMODM BXMODM.BDP
EXE2BIN BBPLUS BBPLUS.BDP
EXE2BIN BASCII BASCII.BDP
Note that if you know assembly language, BACKDOWN provides a fairly
simple interface for adding further protocol modules without requiring
you to recompile the main program.
BRINGING UP BACKDOWN
The full syntax for BACKDOWN is
BD [/Pn|/Hxxx,i] [/Sz] [/C script] [/T] [/U] [script [operands]]
Note that all the command line parameters shown are optional. If you
simply enter BD alone, BACKDOWN will be loaded into memory with the
following defaults: COM1, 2400 bps, no parity, 8 data bits, 1 stop bit,
7-bit screen display, automatic recognition of the CompuServe B+ protocol
enabled, and a script file buffer size of 1K. The command line parameters
specifically related to operating BACKDOWN from a script rather than
interactively are explained in the sidebar "Creating and Using a BACKDOWN
Script." (See Below)
The /Pn command line switch lets you specify any of the standard
PC COM ports, as follows:
/P1 = Port 3F8 Interrupt 4 (COM1)
/P2 = Port 2F8 Interrupt 3 (COM2)
/P3 = Port 3E8 Interrupt 4 (COM3)
/P4 = Port 2E8 Interrupt 3 (COM4)
If you want to use a port that the /Pn switch does not support,
the /Hxxx,i switch lets you specify a particular I/O port and hardware
interrupt. For example, if you have a COM port at address 230h and you
want it to use interrupt 5, you would enter the command BD /H230,5.
Since BACKDOWN uses COM1 as the default, the following three commands
to load the program into memory are functionally identical:
When you have finished using BACKDOWN, you can remove it from memory
by typing the command BD /U. Note that if you try to uninstall BACKDOWN
as it is processing a download or script, it will ask you if you are
sure you want to uninstall it. If you answer yes and the BD/U command
is successful you will get a message indicating that BACKDOWN has been
uninstalled. The only time the /U command will not work is if you loaded
another program after BACKDOWN. In this case simply uninstall that program first.
You can test whether BACKDOWN is actively engaged by using the
/T command line switch. This switch returns an ERRORLEVEL and a screen
message that indicates whether BACKDOWN is installed, and if so, whether
or not it is busy. Specifically,
ERRORLEVEL 2 indicates that BACKDOWN is not installed.
ERRORLEVEL 1 indicates that BACKDOWN is installed, but it is either
running a script or a receiving a download.
ERRORLEVEL 0 indicates that BACKDOWN is installed but is in its "dumb
terminal" mode and so may be uninstalled.
As an example of the /T and /U switches in action, the following
batch file will repeatedly test for activity until BACKDOWN is through
processing and then it will unload the program.
BD /T >NUL
IF ERRORLEVEL 2 GOTO NOTHERE
IF ERRORLEVEL 1 GOTO TESTBD
BD /U >NUL
Echo Backdown now uninstalled!
Echo BACKDOWN not in memory!
When you load BACKDOWN into memory, it looks for any download protocol
modules you may have on your system. These modules each have a .BDP
extension (for BackDown Protocol). BACKDOWN looks for these modules
in either the directory specified by the environment variable BDP or in
the current directory.
You can create the BDP environment variable with the DOS SET
command. For example, if you have stored the protocol modules in your
C:\PCMAG\BACKDOWN directory, you can relay this information to BACKDOWN
by using the command
either from the DOS prompt or, more conveniently, as a line in your
When loading, if BACKDOWN determines that it is already loaded or
that the COM port specified is not in your system, it displays the
appropriate error message and returns to the DOS prompt. Otherwise,
BACKDOWN displays the names of the available protocol modules and
finishes with a message indicating that it has loaded. Until you issue
the BD /U command to unload it, BACKDOWN will remain memory-resident.
Once BACKDOWN is resident in memory, you pop it up by pressing
the key combination Ctrl-Alt-B. The current screen is saved and
replaced with the initial "dumb terminal" screen. This screen doubles
as a noncontextual help screen that can be accessed by pressing F1.
The use of the various other function keys shown in the figure will be
explained shortly. To return to DOS or to your application (keeping
BACKDOWN active if it is downloading a file), the hotkey is Alt-X.
When you are using the ``dumb terminal'' interface, any information
you enter will be sent out over the specified COM port. You can verify
this by typing a few random letters at the keyboard and noting that the
SD (Send Data) light on your modem flickers. Similarly, any characters
received will be displayed. If you're using a Hayes-compatible modem
(as we'll assume for all examples in this article), entering the command
ATV1E1 will set the modem for Verbose Responses (V1) (such as OK or NO
CARRIER) and Echo On (E1), so you can see what you type. After typing
the command, hit the Enter key and the modem should respond "OK".
At this point you can proceed along one of several paths. You can
change BACKDOWN's settings by pressing F2. As we have just illustrated,
you can type specific modem commands to connect to or use a communications
service simply by typing them on the dumb terminal screen and hitting
Enter. By hitting F9, you can initiate a download. You can execute a
script that will perform one or more predetermined functions by hitting
F10. Or you can pop down the TSR and return to your application or to
the DOS prompt by pressing Alt-X.
When you press the Settings key (F2), BACKDOWN displays a four-column
list of the various communications parameters you can set with BACKDOWN.
The first column shows the available baud rates, and the second indicates
the available data bits, parity, and stop bit combinations. The third
column lets you choose how many bits will be used when characters are
displayed on your screen. If you select 7BIT mode (the default), the
high-order bit of incoming data will be stripped off before being shown.
The fourth column selection determines whether automatic CompuServe B+
protocol invocation is enabled or disabled; this will be explained below.
To make a selection from the options shown, simply press the
character that corresponds to it. BACKDOWN will display the setting you
selected and will prompt you for another entry. Hitting Enter returns
you to the dumb terminal mode. After setting BACKDOWN's parameters, you
can enter the necessary modem commands. For example, if your local
ZiffNet access number were 555-1235, you would type
and then hit the Enter key. The modem would dial ZiffNet and respond
with some version of the Connect message.
Any time you want to download a file or capture information, you must
use a protocol. A protocol consists of a set of rules that allows two
computers to talk to each other; both computers must abide by the agreed
upon protocol during the transfer of files. Protocol agreement is
established by a process known as handshaking, which takes place when
the two computers first connect.
Four protocols come with the initial distribution of BACKDOWN:
Xmodem, Xmodem/CRC, CompuServe B+, and ASCII. Among these, Xmodem,
Xmodem/CRC, and CompuServe B+ provide correction facilities to ensure
error-free file transmission. The ASCII protocol allows any information
displayed during the session to be captured to a disk file, but because
it lacks error-correction facilities it provides no assurance that the
data is transferred reliably.
Which protocol should you use? If you are just trying to capture
information that is being displayed on the dumb terminal screen, use
the ASCII protocol. It is the only protocol that performs this function.
For file transfer via ZiffNet or CompuServe, CompuServe B+ is the
protocol of choice. In the absence of CompuServe B+, Xmodem/CRC is the
next best, followed by Xmodem. Xmodem and Xmodem/CRC are implemented with
"relaxed" Xmodem timing (where the timing requirements are not as
stringent), so that they work properly with ZiffNet or CompuServe.
Both Xmodem and Xmodem/CRC use the same basic BXMODM.BDP module.
Systems vary in the exact sequence of events that leads up to a
file download, but the usual scenario runs something like this: Select
the file to download, tell the remote system which protocol you want to
use, wait for the remote system to tell you to start it at your end,
and execute the protocol on your machine. From there, the two computers
enjoy a friendly conversation while transferring the file you requested.
On completion of the transfer, you are usually returned to some type of
To see how BACKDOWN implements this procedure, let's assume that you
want to retrieve the latest copy of CDX.COM from ZifNnet.
First, from the BACKDOWN dumb terminal screen you connect to ZiffNet
by giving your modem the AT commands to dial your local ZiffNet access
number. When you see the Connect message, you press Ctrl-C. The system
then prompts for your user Id and password. After you enter these,
several initial messages will be displayed.
Eventually, you'll get to a prompt (usually an exclamation point),
at which you type
and hit Enter. This will take you to the Utilforum/Tips Forum, where
you will enter the command LIB 2. (All of the PC Magazine utilities are
kept in library 2. PCMAG UTILS)
For this example, we will download CDX.COM using the Xmodem/CRC
protocol. Type the command
DOW CDX.COM /PROTO:XMODEM
and press the Enter key. ZiffNet will respond by giving you some
information about the file and will then ask you to start the protocol.
This means that ZiffNet is ready to send the file.
Now you finally get to press the BACKDOWN Download key (F9), which
will bring up the screen to start the download process. From that screen
you select Xmodem/CRC by typing a C, followed by Enter. You will then be
prompted for a filename, which you must enter and which (optionally) may
include a full path. In this case you type CDX.COM and press Enter.
BACKDOWN tells ZiffNet that it is ready to receive the file, and
the transfer begins. After a few minutes (depending on the speed of your
modem), the file CDX.COM will be on your hard disk and BACKDOWN will tell
you that the transfer has been successful. ZiffNet requires you to press
the Enter key to get back to the LIB prompt. Entering the command BYE
will then disconnect you from ZiffNet.
When using the Xmodem and ASCII protocols, you may enter the filename
to be received when you specify the protocol. In the above example, when
asked for a protocol, you could have entered
and BACKDOWN would not have prompted you again for the filename.
If you are using the CompuServe B+ protocol, the above procedure
must be altered slightly. First, when ZiffNet displays the LIB prompt,
DOW CDX.COM /PROTO:B
Next, instead of prompting you to start the protocol on your machine,
ZiffNet requests that you enter a filename for your computer. The
filename you enter is used to store the information when it is placed
on your local disk. After typing the filename, ZiffNet sends a message
to BACKDOWN requesting that it start a B+ transfer.
This is where your setup choice of B+ Enabled or B+ Disabled comes
in. If you do not have B+ enabled, the request will be ignored and a
"club" character (ASCII 5) will be displayed on your screen. If B+ is
enabled, however, BACKDOWN will automatically load the protocol module
and tell ZiffNet that it is ready to receive. From here on, the transfer
is similar to the Xmodem transfer.
Why would you ever want to disable automatic B+ detection? You would
do so if you are connecting to a service that does not use B+ and that
needs to send you a "club" character (known as an ENQ). In such a case,
disabling CompuServe B+ recognition will prevent BACKDOWN from sending
a response that is not used by the service.
The example above describes a perfect file transfer, but life is
not always perfect, nor are file transfers. The error messages that
BACKDOWN may display during a download are included in the sidebar
The ASCII protocol, unlike the others, captures text just as it is
displayed on the dumb terminal screen. It also lets you enter keystrokes
as if no protocol were running. One noticeable difference is that none
of the function keys work while the ASCII protocol is active.
To cancel any protocol before completion of a file download, you
just press the End key. In response, the ASCII protocol simply closes
the receive file, whereas the Xmodem and CompuServe B+ protocols attempt
to abort the transfer gracefully before returning to the dumb terminal
Remember, while using BACKDOWN to download a file, you may return
to your foreground program at any time except when you are answering
a question that BACKDOWN has displayed for you to answer. You return
to the foreground program by pressing Alt-X.
One final note on downloads: If you initiated the download from
the dumb terminal (as opposed to a script) and you have exited BACKDOWN
and returned to the foreground, BACKDOWN will automatically pop up when
the download is complete.
There are three other function keys that perform important tasks. The
first is the F4 key, which causes BACKDOWN to send a single 0.5-second
break signal. The string <> on-screen tells you that the signal
has been sent. The need for and use of the break function varies from
service to service, but wherever you need it, you've got it.
When you want to disconnect from a service, pressing the F3 key
momentarily drops the voltage of the Data Terminal Ready (DTR) signal
to the modem and displays the string <>. If your modem is
configured to honor DTR, it should disconnect immediately.
If your modem is not configured that way, you may have to type
something like +++ATH and hit Enter. The +++ usually causes a Hayes
modem to return to the command state; the ATH command tells the modem
to hang up.
Generally, you should log out of a remote service before
disconnecting with F3. Logging out is the best way to be sure that
the service knows you have completed your session. This can avoid
anything from a minor annoyance to additional charges for connect
time. In many cases, the remote service breaks the connection
automatically as the result of a logout command.
Finally, the F10 key allows you to enter the name of a BACKDOWN
script to be executed. Scripts free you from regularly retyping commands
that perform everyday tasks, such as dialing a number, logging you into
a service, or retrieving files. A sample script for logging onto ZiffNet
is shown in Figure 4 (See Below), but it must be compiled before BACKDOWN
can run it. After pressing F10 you can enter not only the script name but
also up to nine blank delimited operands after that name.
Figure 5 (See Below) provides an example of how such parameters are used,
but for a full discussion of BACKDOWN's script language and procedures
you should turn to the sidebar "Creating and Using a BACKDOWN Script."
There are several things that BACKDOWN does not do. For instance,
it has no upload capability. Nor does it provide any terminal emulation
beyond a basic teletype-style interface. Further, its script language is
more limited than we would like it to be.
Even in the absence of these features, however, we hope you are among
the many PC Magazine readers who will not only use BACKDOWN but will
wonder how they ever got along without it.
Bob Flanders is president and senior systems analyst and Michael Holmes
is vice president and senior systems analyst at NCI Systems in Annandale,
SIDEBAR 1: CREATING AND USING A BACKDOWN SCRIPT
by Michael Holmes
Typing in the same commands every time you use a communications service
is tedious and time-consuming. By using BACKDOWN's script language you
can automate such repetitive procedures. With a short script you could
log on to a BBS or set up to download a file; a longer script might
handle the whole session, from when you log-on through when you hang-up.
The three optional command line parameters that relate to the use
of BACKDOWN scripts were not explained in the main article. These are
BD [Sn] [/C script] [script [operands]]
When loading initially, BACKDOWN normally reserves a 1KB buffer to hold
a compiled script file and store script variables. Should you write an
exceptionally long script (or one with many script variables), you may
need to use the /S switch to increase the size of the script buffer
to n bytes. For example, if you have a script that requires 1,500 bytes
and you are starting BACKDOWN on COM port 2, you would enter
BD /P2 /S1500
You can write script source files with any text or word processor that
produces an ASCII file. To save memory space and execution time, this
file must be compiled by BACKDOWN before it can be used. To compile a
script file, you enter the following command at the DOS prompt:
BD /C script
Although it is not mandatory, your ASCII script source file should
normally be given the file extension .BDS. (If no extension is specified,
BACKDOWN assumes this extension.) The compiled script will have the same
filename but will automatically be given a .BDC extension. On completion
of the compile, BACKDOWN displays the size of the .BDC file. The number
shown is the minimum number of bytes needed for the script buffer;
depending on the number and length of parameters used in the script,
more buffer space may be required.
Once written and compiled, a BACKDOWN script file can be executed
either from the command line or by pressing F10 from the interactive dumb
terminal screen. For example, to execute the TESTPARM.BDS script shown
in Figure 5, passing its space-delimited parameters to it, you could
enter the following command:
BD TESTPARM Alpha Beta Gamma
Note that if this command were entered when BACKDOWN was not already
resident in memory, the utility would automatically be loaded and the
script would be started in the background. The same script and parameters
could be specified after installing BACKDOWN by pressing F10.
THE BACKDOWN SCRIPT LANGUAGE
In preparing an ASCII script source file for compilation, the BACKDOWN
script language recognizes 14 commands, together with their operands.
These are listed, explained, and exemplified below.
The operands for the O (Options) command generally correspond to the
settings that may be selected by pressing F2 after BACKDOWN is
memory-resident. These options include communications parameters for
BACKDOWN's COM port, its display mode, and automatic recognition of
CompuServe's B+ protocol. In addition, the O command can control case
recognition of responses from the communications service.
In addition to the baud rates listed, BACKDOWN supports data
formats of no parity, 8 data and 1 stop bit (N81); even parity, 7 data
and 1 stop bit (E71); and odd parity, 7 data and 1 stop bit (O71). The
7BIT option strips the high-order bit from characters before they are
displayed. With this option specified, data will display correctly if
your communications parameters are none,8,1 while those of the service
are set at even or odd,7,1. The 8BIT operand causes the display of all
characters as full 8-bit values, with no masking of the most significant
The B+ and B- operands respectively enable and disable the
automatic recognition of the CompuServe B+ protocol. The CASE operand
enables case recognition of responses to the R command (explained below);
NOCASE disables case recognition. For example, if you specified NOCASE
and used the command
any string containing the word forum would satisfy the wait, regardless
Multiple operands, separated by a space, may appear on the same
line as an O statement, and the O statement can occur more than once in
O 2400 N81 7BIT B+ NOCASE
The S (Send String) command sends a text string to the remote computer.
This command may contain embedded control characters, such as ^M (carriage
return) or ^G (bell). It may also contain references to variables that
will be replaced with specified character strings at execution time.
(See the P command below for more about variables.)
S DOW PCSPOO.ZIP /PROTO:B^M
The N (Notify Operator) command displays a text string on BACKDOWN's
screen when the TSR is popped up. The text string for this command, like
that for the S command, can contain both control codes and replacement
N ^G -- Download complete -- ^G^M
The R (Wait for Remote) command waits for the data stream from a remote
computer to contain a specified character string (text). A time-out occurs
if the remote does not send the proper characters in the time specified
by the T command (explained next).
The text string for the R command may contain control characters,
but replaceable variables are not supported. The CASE and NOCASE option
of the O command determines whether the R command is case-sensitive.
T nn [label]
The T (Set Time-out) command sets a time-out value of nn seconds, to
be used by the R command. The optional label designates a specified
statement to be executed should a time-out occur. If no label is given,
control passes to the next statement in the script.
T 60 NotSeen
S GO ZNT:UTILFOR^M
R Forum !
n Timeout waiting for Forum prompt.^M
The H (Hangup) command causes the DTR line on the serial port to drop
momentarily, disconnecting the machine from a remote service.
D p [filename]
The D (Download) command invokes a specified download protocol module,
p. The protocol letter is the same as that used in interactive mode.
The additional download filename is optional, but the Xmodem and ASCII protocols will prompt for it if one is not specified.
When the ASCII protocol is invoked, even from a script, control
is returned to the keyboard. After opening the received file, ASCII
sends a carriage return to the remote service. Thereafter, characters
entered at the keyboard are sent out the active COM port; received
characters are both displayed and placed in the download file. Pressing
the End key stops the download and returns control to the script. If 30
seconds elapse with no data received, the ASCII protocol closes the
receive file and returns to the script.
S TYPE CDX.DOC
D A CDX.DOC
In the example above, note that the S command does not end with a
carriage return (^M). This is because the ASCII protocol will send a
carriage return when it starts running.
If Xmodem is used, downloading begins as soon as the receive file
is opened and progresses until the download is complete. To cancel
receipt of a file prematurely, press the End key. The following example
shows script statements to start an Xmodem download from ZiffNet.
S DOW CHKFRG.ZIP /PROTO:XMODEM^M
D X C:\DL\CHKFRG.ZIP
CompuServe's B+ protocol should not be invoked with the D statement.
The B+ invocation occurs automatically when the system is ready to send
a file. Use the R or the W command to wait for the invocation of the
CompuServe B+ protocol.
S DOW SLICE.ZIP /PROTO:B
P letter prompt_string
The P (Prompt and Reply) command displays the specified prompt string
and loads the response into a variable designated by a single letter in
the range from A to Z. Variables are referenced by placing a percent
sign in front of the letter of each variable.
P A Enter your name:
N ^M Your name is: %A^M
= letter [text]
The = (Equate) command assigns a text string to a script variable letter.
When the text operand is omitted, BACKDOWN assigns a null string to the
= F ZCOPY.COM
The W (Wait) command temporarily halts execution of the script for
nn seconds. During this period of time, any arriving characters are
displayed on BACKDOWN's pop-up screen.
The E (Echo Control) command sets the display characteristics to
n during script execution. These are the values of n:
0 stops display of all data.
1 displays only the data received by BACKDOWN. The host may
echo any data sent from BACKDOWN.
2 displays only data sent by BACKDOWN. Received data is not displayed.
3 displays data sent from and received by BACKDOWN. This may
result in characters appearing twice on the screen.
If no E command is specified, the value defaults to 1.
The G (Goto) command transfers control to the point in the script at
which label is found. The transfer is an unconditional forward or
The :Label command marks a particular point in a script as the target
for a G or a T command.
S DOW LASERL.ZIP /PROTO:B
You can include documentation in your scripts by using comment statements.
A comment statement contains a semicolon as the first character on the
line. Any text appearing after the semicolon is ignored by the compiler.
SIDEBAR 2: BACKDOWN MESSAGES
by Bob Flanders
When two computers have to communicate across telephone lines, occasional
errors are bound to occur. When this happens, BACKDOWN will notify you,
either on the screen directly (if you're working interactively) or by
popping up over your application. Many of the messages the program sends
depend on the specific protocol you have selected, so they are listed by
protocol and followed by brief explanations.
XMODEM: Timeout, protocol ended
B+: Timeout, protocol ended
ASCII: No Characters seen for 30 seconds, protocol ended
The download is canceled when the message above is displayed.
XMODEM: Too many errors, download cancelled
B+: Too many errors
As a transfer proceeds, BACKDOWN is constantly checking for errors.
If too many errors occur in a row, the download is canceled.
B+: Receiving filename
The message showing the name of the file being received is displayed
when a transfer begins with the CompuServe B+ protocol.
XMODEM: User cancelled download
B+: Download cancelled
If you press the End key during a transfer, BACKDOWN will display this
message and attempt to end the transfer gracefully.
XMODEM: Sender cancelled download
If the service you are using stops the download, BACKDOWN tells you
about it with this message.
XMODEM: Write error. Protocol aborted
B+: Aborted: write error
This error occurs if BACKDOWN is unable to write data to the file you
have specified, as may happen, for example, if the disk fills up.
XMODEM: Packet sequence error
This is an unusual error in Xmodem where a piece of the file being
transferred has been irrecoverably lost, so the transfer is canceled.
XMODEM: Download completed OK
B+: Download completed OK
This message appears after a successful download.
ZIFFNET.BDS COMPLETE LISTING
Figure 4: After you compile it under BACKDOWN, this sample script will log you onto ZiffNet. Note that the user ID and password shown must be replaced with your user Id and password.
; Dial up Ziffnet and log in.
; This script is designed to work with a modem using an AT-command set.
O 2400 8N1 7BIT B+ NOCASE
; Init the modem
T 5 ReInit
; Only reaches here if first init fails
T 5 FailInit
; Die gracefully if modem does not respond
N Modem did not respond^M
; Dial ZiffNet
N ^MDialing ..
T 60 NoAnswer
; Replace "xxx-xxxx" with your local Compuserve telephone number
; Send userid
R User ID:
; Replace "yyyyy,yyy" with your account number
; Send Password
; Replace "Your:password:Here" with your password
N ^M^G --- Login Complete --- ^G^M
: NoAnswer - Hangup and tell operator
N ^G -- Line busy or your modem isn't working -- ^G^M
; Recompile this script with the command BD /C ZIFFNET
TESTPARM.BDS COMPLETE LISTING
Figure 5: This short script demonstrates how command line parameters are specified. Much like a batch file's parameters, they are referenced as %1, %2, and so on.
If you have the following script called TESTPARM:
N Parm 1 is %1^M
N Parm 2 is %2^M
N Parm 3 is %3^M
Here is a sample execution:
Script name: TESTPARM Alpha Beta Gamma
Parm 1 is Alpha
Parm 2 is Beta
Parm 3 is Gamma