home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 09 / bd.doc < prev    next >
Text File  |  1992-04-22  |  32KB  |  835 lines

  1. BACKDOWN.EXE (Version 1.0)
  2.  
  3. ------------------------------------------------------------------------
  4. Bob Flanders and Michael Holmes                            May 12, 1992 (Utilities)
  5. ------------------------------------------------------------------------
  6.  
  7. BACKDOWN: A TSR (terminate-and-stay-resident) utility, BACKDOWN lets you
  8. start and manage communications sessions and file downloads in the
  9. background while you continue working in your foreground application.
  10. You can run BACKDOWN interactively, or you can use its script facilities
  11. to automate all or part of its operations.
  12.  
  13.      Specifically, BACKDOWN provides five major functions:
  14. a "dumb terminal" interface, script execution, a script compiler,
  15. protocol-based download capability, and background execution. The program
  16. requires DOS 3.1 or later and occupies about 16K when resident in memory.
  17.  
  18.      A complete set of source code files are available in case you wish
  19. to study or customize them. They are included in BD.ZIP or listed as
  20. BDSRC.ZIP. The source can be assembled with Microsoft MASM 5.1 or 6.0 or
  21. Borland's Turbo Assembler 2.5 or 3.0. (Other assemblers may work, but
  22. we have tested it only using these.) Using the Microsoft assembler, you
  23. create BD.EXE from its .ASM source with the two commands
  24.  
  25. MASM BD;
  26. LINK BD;
  27.  
  28. The statements needed to assemble the BACKDOWN downloading protocol
  29. files are as follows:
  30.  
  31. MASM BXMODM;
  32. LINK BXMODM;
  33. EXE2BIN BXMODM BXMODM.BDP
  34.  
  35. MASM BBPLUS;
  36. LINK BBPLUS;
  37. EXE2BIN BBPLUS BBPLUS.BDP
  38.  
  39. MASM BASCII;
  40. LINK BASCII;
  41. EXE2BIN BASCII BASCII.BDP
  42.  
  43. Note that if you know assembly language, BACKDOWN provides a fairly
  44. simple interface for adding further protocol modules without requiring
  45. you to recompile the main program.
  46.  
  47. BRINGING UP BACKDOWN
  48. The full syntax for BACKDOWN is
  49.  
  50. BD [/Pn|/Hxxx,i] [/Sz] [/C script] [/T] [/U] [script [operands]]
  51.  
  52.  
  53. Note that all the command line parameters shown are optional. If you
  54. simply enter BD alone, BACKDOWN will be loaded into memory with the
  55. following defaults: COM1, 2400 bps, no parity, 8 data bits, 1 stop bit,
  56. 7-bit screen display, automatic recognition of the CompuServe B+ protocol
  57. enabled, and a script file buffer size of 1K. The command line parameters
  58. specifically related to operating BACKDOWN from a script rather than
  59. interactively are explained in the sidebar "Creating and Using a BACKDOWN
  60. Script." (See Below)
  61.  
  62.      The /Pn command line switch lets you specify any of the standard
  63. PC COM ports, as follows:
  64.  
  65. /P1 = Port 3F8 Interrupt 4 (COM1)
  66. /P2 = Port 2F8 Interrupt 3 (COM2)
  67. /P3 = Port 3E8 Interrupt 4 (COM3)
  68. /P4 = Port 2E8 Interrupt 3 (COM4)
  69.  
  70. If you want to use a port that the /Pn switch does not support,
  71. the /Hxxx,i switch lets you specify a particular I/O port and hardware
  72. interrupt. For example, if you have a COM port at address 230h and you
  73. want it to use interrupt 5, you would enter the command BD /H230,5.
  74. Since BACKDOWN uses COM1 as the default, the following three commands
  75. to load the program into memory are functionally identical:
  76.  
  77. BD
  78. BD /P1
  79. BD /H3F8,4
  80.  
  81. When you have finished using BACKDOWN, you can remove it from memory
  82. by typing the command BD /U. Note that if you try to uninstall BACKDOWN
  83. as it is  processing a download or script, it will ask you if you are
  84. sure you want to uninstall it. If you answer yes and the BD/U command
  85. is successful you will get a message indicating that BACKDOWN has been
  86. uninstalled. The only time the /U command will not work is if you loaded
  87. another program after BACKDOWN. In this case simply uninstall that program first.
  88.  
  89.      You can test whether BACKDOWN is actively engaged by using the
  90. /T command line switch. This switch returns an ERRORLEVEL and a screen
  91. message that indicates whether BACKDOWN is installed, and if so, whether
  92. or not it is busy. Specifically,
  93.  
  94.   ERRORLEVEL 2 indicates that BACKDOWN is not installed.
  95.  
  96.   ERRORLEVEL 1 indicates that BACKDOWN is installed, but it is either
  97.   running a script or a receiving a download.
  98.  
  99.   ERRORLEVEL 0 indicates that BACKDOWN is installed but is in its "dumb
  100.   terminal" mode and so may be uninstalled.
  101.  
  102.  
  103.      As an example of the /T and /U switches in action, the following
  104. batch file will repeatedly test for activity until BACKDOWN is through
  105. processing and then it will unload the program.
  106.  
  107. @echo off
  108. :testbd
  109. BD /T >NUL
  110. IF ERRORLEVEL 2 GOTO NOTHERE
  111. IF ERRORLEVEL 1 GOTO TESTBD
  112. BD /U >NUL
  113. Echo Backdown now uninstalled!
  114. GOTO END
  115. :NOTHERE
  116. Echo BACKDOWN not in memory!
  117. :END
  118.  
  119. When you load BACKDOWN into memory, it looks for any download protocol
  120. modules you may have on your system. These modules each have a .BDP
  121. extension (for BackDown Protocol). BACKDOWN looks for these modules
  122. in either the directory specified by the environment variable BDP or in
  123. the current directory.
  124.  
  125.      You can create the BDP environment variable with the DOS SET
  126. command. For example, if you have stored the protocol modules in your
  127. C:\PCMAG\BACKDOWN directory, you can relay this information to BACKDOWN
  128. by using the command
  129.  
  130. SET BDP=C:\PCMAG\BACKDOWN
  131.  
  132. either from the DOS prompt or, more conveniently, as a line in your
  133. AUTOEXEC.BAT file.
  134.  
  135.      When loading, if BACKDOWN determines that it is already loaded or
  136. that the COM port specified is not in your system, it displays the
  137. appropriate error message and returns to the DOS prompt. Otherwise,
  138. BACKDOWN displays the names of the available protocol modules and
  139. finishes with a message indicating that it has loaded. Until you issue
  140. the BD /U command to unload it, BACKDOWN will remain memory-resident.
  141.  
  142.      Once BACKDOWN is resident in memory, you pop it up by pressing
  143. the key combination Ctrl-Alt-B. The current screen is saved and
  144. replaced with the initial "dumb terminal" screen. This screen doubles
  145. as a noncontextual help screen that can be accessed by pressing F1.
  146. The use of the various other function keys shown in the figure will be
  147. explained shortly. To return to DOS or to your application (keeping
  148. BACKDOWN active if it is downloading a file), the hotkey is Alt-X.
  149.  
  150.      When you are using the ``dumb terminal'' interface, any information
  151. you enter will be sent out over the specified COM port. You can verify
  152. this by typing a few random letters at the keyboard and noting that the
  153. SD (Send Data) light on your modem flickers. Similarly, any characters
  154. received will be displayed. If you're using a Hayes-compatible modem
  155. (as we'll assume for all examples in this article), entering the command
  156. ATV1E1 will set the modem for Verbose Responses (V1) (such as OK or NO
  157. CARRIER) and Echo On (E1), so you can see what you type. After typing
  158. the command, hit the Enter key and the modem should respond "OK".
  159.  
  160.      At this point you can proceed along one of several paths. You can
  161. change BACKDOWN's settings by pressing F2. As we have just illustrated,
  162. you can type specific modem commands to connect to or use a communications
  163. service simply by typing them on the dumb terminal screen and hitting
  164. Enter. By hitting F9, you can initiate a download. You can execute a
  165. script that will perform one or more predetermined functions by hitting
  166. F10. Or you can pop down the TSR and return to your application or to
  167. the DOS prompt by pressing Alt-X. 
  168.  
  169. SELECTING SETTINGS
  170. When you press the Settings key (F2), BACKDOWN displays a four-column
  171. list of the various communications parameters you can set with BACKDOWN.
  172. The first column shows the available baud rates, and the second indicates
  173. the available data bits, parity, and stop bit combinations. The third
  174. column lets you choose how many bits will be used when characters are
  175. displayed on your screen. If you select 7BIT mode (the default), the
  176. high-order bit of incoming data will be stripped off before being shown.
  177. The fourth column selection determines whether automatic CompuServe B+
  178. protocol invocation is enabled or disabled; this will be explained below.
  179.  
  180.      To make a selection from the options shown, simply press the
  181. character that corresponds to it. BACKDOWN will display the setting you
  182. selected and will prompt you for another entry. Hitting Enter returns
  183. you to the dumb terminal mode. After setting BACKDOWN's parameters, you
  184. can enter the necessary modem commands. For example, if your local
  185. ZiffNet access number were 555-1235, you would type 
  186.  
  187. ATDT555-1235
  188.  
  189. and then hit the Enter key. The modem would dial ZiffNet and respond
  190. with some version of the Connect message.
  191.  
  192. DOWNLOADING FILES
  193.  
  194. Any time you want to download a file or capture information, you must
  195. use a protocol. A protocol consists of a set of rules that allows two
  196. computers to talk to each other; both computers must abide by the agreed
  197. upon protocol during the transfer of files. Protocol agreement is
  198. established by a process known as handshaking, which takes place when
  199. the two computers first connect.
  200.  
  201.      Four protocols come with the initial distribution of BACKDOWN:
  202. Xmodem, Xmodem/CRC, CompuServe B+, and ASCII. Among these, Xmodem,
  203. Xmodem/CRC, and CompuServe B+ provide correction facilities to ensure
  204. error-free file transmission. The ASCII protocol allows any information
  205. displayed during the session to be captured to a disk file, but because
  206. it lacks error-correction facilities it provides no assurance that the
  207. data is transferred reliably.
  208.  
  209.      Which protocol should you use? If you are just trying to capture
  210. information that is being displayed on the dumb terminal screen, use
  211. the ASCII protocol. It is the only protocol that performs this function.
  212.  
  213.      For file transfer via ZiffNet or CompuServe, CompuServe B+ is the
  214. protocol of choice. In the absence of CompuServe B+, Xmodem/CRC is the
  215. next best, followed by Xmodem. Xmodem and Xmodem/CRC are implemented with
  216. "relaxed" Xmodem timing (where the timing requirements are not as
  217. stringent), so that they work properly with ZiffNet or CompuServe.
  218. Both Xmodem and Xmodem/CRC use the same basic BXMODM.BDP module.
  219.  
  220.      Systems vary in the exact sequence of events that leads up to a
  221. file download, but the usual scenario runs something like this: Select
  222. the file to download, tell the remote system which protocol you want to
  223. use, wait for the remote system to tell you to start it at your end,
  224. and execute the protocol on your machine. From there, the two computers
  225. enjoy a friendly conversation while transferring the file you requested.
  226. On completion of the transfer, you are usually returned to some type of
  227. command prompt.
  228.  
  229.      To see how BACKDOWN implements this procedure, let's assume that you
  230. want to retrieve the latest copy of CDX.COM from ZifNnet. 
  231.  
  232.      First, from the BACKDOWN dumb terminal screen you connect to ZiffNet
  233. by giving your modem the AT commands to dial your local ZiffNet access
  234. number. When you see the Connect message, you press Ctrl-C. The system
  235. then prompts for your user Id and password. After you enter these,
  236. several initial messages will be displayed.
  237.  
  238.       Eventually, you'll get to a prompt (usually an exclamation point),
  239. at which you type 
  240.  
  241. GO ZNT:UTILFOR
  242.  
  243. and hit Enter. This will take you to the Utilforum/Tips Forum, where
  244. you will enter the command LIB 2. (All of the PC Magazine utilities are
  245. kept in library 2. PCMAG UTILS)
  246.  
  247.      For this example, we will download CDX.COM using the Xmodem/CRC
  248. protocol. Type the command
  249.  
  250. DOW CDX.COM /PROTO:XMODEM
  251.  
  252. and press the Enter key. ZiffNet will respond by giving you some
  253. information about the file and will then ask you to start the protocol.
  254. This means that ZiffNet is ready to send the file.
  255.  
  256.      Now you finally get to press the BACKDOWN Download key (F9), which
  257. will bring up the screen to start the download process. From that screen
  258. you select Xmodem/CRC by typing a C, followed by Enter. You will then be
  259. prompted for a filename, which you must enter and which (optionally) may
  260. include a full path. In this case you type CDX.COM and press Enter.
  261.  
  262.       BACKDOWN tells ZiffNet that it is ready to receive the file, and
  263. the transfer begins. After a few minutes (depending on the speed of your
  264. modem), the file CDX.COM will be on your hard disk and BACKDOWN will tell
  265. you that the transfer has been successful. ZiffNet requires you to press
  266. the Enter key to get back to the LIB prompt. Entering the command BYE
  267. will then disconnect you from ZiffNet.
  268.  
  269.      When using the Xmodem and ASCII protocols, you may enter the filename
  270. to be received when you specify the protocol. In the above example, when
  271. asked for a protocol, you could have entered
  272.  
  273. C CDX.COM
  274.  
  275. and BACKDOWN would not have prompted you again for the filename.
  276.  
  277.      If you are using the CompuServe B+ protocol, the above procedure
  278. must be altered slightly. First, when ZiffNet displays the LIB prompt,
  279. you respond
  280.  
  281. DOW CDX.COM /PROTO:B
  282.  
  283. Next, instead of prompting you to start the protocol on your machine,
  284. ZiffNet requests that you enter a filename for your computer. The
  285. filename you enter is used to store the information when it is placed
  286. on your local disk. After typing the filename, ZiffNet sends a message
  287. to BACKDOWN requesting that it start a B+ transfer. 
  288.  
  289.      This is where your setup choice of B+ Enabled or B+ Disabled comes
  290. in. If you do not have B+ enabled, the request will be ignored and a
  291. "club" character (ASCII 5) will be displayed on your screen. If B+ is
  292. enabled, however, BACKDOWN will automatically load the protocol module
  293. and tell ZiffNet that it is ready to receive. From here on, the transfer
  294. is similar to the Xmodem transfer. 
  295.  
  296.      Why would you ever want to disable automatic B+ detection? You would
  297. do so if you are connecting to a service that does not use B+ and that
  298. needs to send you a "club" character (known as an ENQ). In such a case,
  299. disabling CompuServe B+ recognition will prevent BACKDOWN from sending
  300. a response that is not used by the service.
  301.  
  302.      The example above describes a perfect file transfer, but life is
  303. not always perfect, nor are file transfers. The error messages that
  304. BACKDOWN may display during a download are included in the sidebar
  305. "BACKDOWN Messages."
  306.  
  307.      The ASCII protocol, unlike the others, captures text just as it is
  308. displayed on the dumb terminal screen. It also lets you enter keystrokes
  309. as if no protocol were running. One noticeable difference is that none
  310. of the function keys work while the ASCII protocol is active.
  311.  
  312.      To cancel any protocol before completion of a file download, you
  313. just press the End key. In response, the ASCII protocol simply closes
  314. the receive file, whereas the Xmodem and CompuServe B+ protocols attempt
  315. to abort the transfer gracefully before returning to the dumb terminal
  316. or script. 
  317.  
  318.      Remember, while using BACKDOWN to download a file, you may return
  319. to your foreground program at any time except when you are answering
  320. a question that BACKDOWN has displayed for you to answer. You return
  321. to the foreground program by pressing Alt-X.
  322.  
  323.      One final note on downloads: If you initiated the download from
  324. the dumb terminal (as opposed to a script) and you have exited BACKDOWN
  325. and returned to the foreground, BACKDOWN will automatically pop up when
  326. the download is complete.
  327.  
  328. ADDITIONAL FUNCTIONS
  329.  
  330. There are three other function keys that perform important tasks. The
  331. first is the F4 key, which causes BACKDOWN to send a single 0.5-second
  332. break signal. The string <<BREAK>> on-screen tells you that the signal
  333. has been sent. The need for and use of the break function varies from
  334. service to service, but wherever you need it, you've got it.
  335.  
  336.      When you want to disconnect from a service, pressing the F3 key
  337. momentarily drops the voltage of the Data Terminal Ready (DTR) signal
  338. to the modem and displays the string <<HANGUP>>. If your modem is
  339. configured to honor DTR, it should disconnect immediately.
  340.  
  341.      If your modem is not configured that way, you may have to type
  342. something like +++ATH and hit Enter. The +++ usually causes a Hayes
  343. modem to return to the command state; the ATH command tells the modem
  344. to hang up.
  345.  
  346.      Generally, you should log out of a remote service before
  347. disconnecting with F3. Logging out is the best way to be sure that
  348. the service knows you have completed your session. This can avoid
  349. anything from a minor annoyance to additional charges for connect
  350. time. In many cases, the remote service breaks the connection
  351. automatically as the result of a logout command.
  352.  
  353.       Finally, the F10 key allows you to enter the name of a BACKDOWN
  354. script to be executed. Scripts free you from regularly retyping commands
  355. that perform everyday tasks, such as dialing a number, logging you into
  356. a service, or retrieving files. A sample script for logging onto ZiffNet
  357. is shown in Figure 4 (See Below), but it must be compiled before BACKDOWN
  358. can run it. After pressing F10 you can enter not only the script name but
  359. also up to nine blank delimited operands after that name.
  360. Figure 5 (See Below) provides an example of how such parameters are used,
  361. but for a full discussion of BACKDOWN's script language and procedures
  362. you should turn to the sidebar "Creating and Using a BACKDOWN Script."
  363.  
  364.      There are several things that BACKDOWN does not do. For instance,
  365. it has no upload capability. Nor does it provide any terminal emulation
  366. beyond a basic teletype-style interface. Further, its script language is
  367. more limited than we would like it to be.
  368.  
  369.      Even in the absence of these features, however, we hope you are among
  370. the many PC Magazine readers who will not only use BACKDOWN but will
  371. wonder how they ever got along without it.
  372.  
  373. Bob Flanders is president and senior systems analyst and Michael Holmes
  374. is vice president and senior systems analyst at NCI Systems in Annandale,
  375. Virgina.
  376. -----------------------------------------------------------------------------
  377.  
  378. SIDEBAR 1: CREATING AND USING A BACKDOWN SCRIPT
  379.  
  380. by Michael Holmes
  381.  
  382. Typing in the same commands every time you use a communications service
  383. is tedious and time-consuming. By using BACKDOWN's script language you
  384. can automate such repetitive procedures. With a short script you could
  385. log on to a BBS or set up to download a file; a longer script might
  386. handle the whole session, from when you log-on through when you hang-up.
  387.  
  388.      The three optional command line parameters that relate to the use
  389. of BACKDOWN scripts were not explained in the main article. These are
  390.  
  391. BD [Sn] [/C script] [script [operands]]
  392.  
  393. When loading initially, BACKDOWN normally reserves a 1KB buffer to hold
  394. a compiled script file and store script variables. Should you write an
  395. exceptionally long script (or one with many script variables), you may
  396. need to use the /S switch to increase the size of the script buffer
  397. to n bytes. For example, if you have a script that requires 1,500 bytes
  398. and you are starting BACKDOWN on COM port 2, you would enter
  399.  
  400. BD /P2 /S1500
  401.  
  402. You can write script source files with any text or word processor that
  403. produces an ASCII file. To save memory space and execution time, this
  404. file must be compiled by BACKDOWN before it can be used. To compile a
  405. script file, you enter the following command at the DOS prompt:
  406.  
  407. BD /C script
  408.  
  409. Although it is not mandatory, your ASCII script source file should
  410. normally be given the file extension .BDS. (If no extension is specified,
  411. BACKDOWN assumes this extension.) The compiled script will have the same
  412. filename but will automatically be given a .BDC extension. On completion
  413. of the compile, BACKDOWN displays the size of the .BDC file. The number
  414. shown is the minimum number of bytes needed for the script buffer;
  415. depending on the number and length of parameters used in the script,
  416. more buffer space may be required.
  417.  
  418.       Once written and compiled, a BACKDOWN script file can be executed
  419. either from the command line or by pressing F10 from the interactive dumb
  420. terminal screen. For example, to execute the TESTPARM.BDS script shown
  421. in Figure 5, passing its space-delimited parameters to it, you could
  422. enter the following command:
  423.  
  424. BD TESTPARM Alpha Beta Gamma
  425.  
  426. Note that if this command were entered when BACKDOWN was not already
  427. resident in memory, the utility would automatically be loaded and the
  428. script would be started in the background. The same script and parameters
  429. could be specified after installing BACKDOWN by pressing F10.
  430.  
  431. THE BACKDOWN SCRIPT LANGUAGE
  432.  
  433. In preparing an ASCII script source file for compilation, the BACKDOWN
  434. script language recognizes 14 commands, together with their operands.
  435. These are listed, explained, and exemplified below.
  436.  
  437. Command
  438.  
  439. O [300|1200|2400|9600]
  440.   [N81|E71|O71]
  441.   [7BIT|8BIT]
  442.   [B+|B-]
  443.   [CASE|NOCASE]
  444.  
  445. The operands for the O (Options) command generally correspond to the
  446. settings that may be selected by pressing F2 after BACKDOWN is
  447. memory-resident. These options include communications parameters for
  448. BACKDOWN's COM port, its display mode, and automatic recognition of
  449. CompuServe's B+ protocol. In addition, the O command can control case
  450. recognition of responses from the communications service.
  451.  
  452.      In addition to the baud rates listed, BACKDOWN supports data
  453. formats of no parity, 8 data and 1 stop bit (N81); even parity, 7 data
  454. and 1 stop bit (E71); and odd parity, 7 data and 1 stop bit (O71). The
  455. 7BIT option strips the high-order bit from characters before they are
  456. displayed. With this option specified, data will display correctly if
  457. your communications parameters are none,8,1 while those of the service
  458. are set at even or odd,7,1. The 8BIT operand causes the display of all
  459. characters as full 8-bit values, with no masking of the most significant
  460. bit.
  461.  
  462.       The B+ and B- operands respectively enable and disable the
  463. automatic recognition of the CompuServe B+ protocol. The CASE operand
  464. enables case recognition of responses to the R command (explained below);
  465. NOCASE disables case recognition. For example, if you specified NOCASE
  466. and used the command
  467.  
  468. R FORUM
  469.  
  470. any string containing the word forum would satisfy the wait, regardless
  471. of case.
  472.  
  473.      Multiple operands, separated by a space, may appear on the same
  474. line as an O statement, and the O statement can occur more than once in
  475. the script.
  476. Example:
  477.  
  478. O 2400 N81 7BIT B+ NOCASE
  479.  
  480.  
  481. Command
  482.  
  483. S text
  484.  
  485. The S (Send String) command sends a text string to the remote computer.
  486. This command may contain embedded control characters, such as ^M (carriage
  487. return) or ^G (bell). It may also contain references to variables that
  488. will be replaced with specified character strings at execution time.
  489. (See the P command below for more about variables.)
  490. For example:
  491.  
  492. S DOW PCSPOO.ZIP /PROTO:B^M
  493.  
  494. Command
  495.  
  496. N text
  497.  
  498. The N (Notify Operator) command displays a text string on BACKDOWN's
  499. screen when the TSR is popped up. The text string for this command, like
  500. that for the S command, can contain both control codes and replacement
  501. variables.
  502. For example:
  503.  
  504. N ^G -- Download complete -- ^G^M
  505.  
  506. Command
  507.  
  508. R text
  509.  
  510. The R (Wait for Remote) command waits for the data stream from a remote
  511. computer to contain a specified character string (text). A time-out occurs
  512. if the remote does not send the proper characters in the time specified
  513. by the T command (explained next).
  514.  
  515.      The text string for the R command may contain control characters,
  516. but replaceable variables are not supported. The CASE and NOCASE option
  517. of the O command determines whether the R command is case-sensitive.
  518. For example:
  519.  
  520. R Userid:
  521.  
  522. Command
  523.  
  524. T nn [label]
  525.  
  526. The T (Set Time-out) command sets a time-out value of nn seconds, to
  527. be used by the R command. The optional label designates a specified
  528. statement to be executed should a time-out occur. If no label is given,
  529. control passes to the next statement in the script.
  530. For example:
  531.  
  532. T 60 NotSeen
  533. S GO ZNT:UTILFOR^M
  534. R Forum !
  535.    .
  536.    .
  537.  
  538. :NotSeen
  539. n Timeout waiting for Forum prompt.^M
  540. s bye^M
  541.  
  542. Command
  543.  
  544. H
  545.  
  546. The H (Hangup) command causes the DTR line on the serial port to drop
  547. momentarily, disconnecting the machine from a remote service.
  548. For example:
  549.  
  550. H
  551.  
  552. Command
  553.  
  554. D p [filename]
  555.  
  556. The D (Download) command invokes a specified download protocol module,
  557. p.  The protocol letter is the same as that used in interactive mode.
  558. The additional download filename is optional, but the Xmodem and ASCII protocols will prompt for it if one is not specified.
  559.  
  560.      When the ASCII protocol is invoked, even from a script, control
  561. is returned to the keyboard. After opening the received file, ASCII
  562. sends a carriage return to the remote service. Thereafter, characters
  563. entered at the keyboard are sent out the active COM port; received
  564. characters are both displayed and placed in the download file. Pressing
  565. the End key stops the download and returns control to the script. If 30
  566. seconds elapse with no data received, the ASCII protocol closes the
  567. receive file and returns to the script.
  568. For example:
  569.  
  570. R LIB
  571. S TYPE CDX.DOC
  572. D A CDX.DOC
  573.  
  574. In the example above, note that the S command does not end with a
  575. carriage return (^M). This is because the ASCII protocol will send a
  576. carriage return when it starts running.
  577.  
  578.      If Xmodem is used, downloading begins as soon as the receive file
  579. is opened and progresses until the download is complete. To cancel
  580. receipt of a file prematurely, press the End key. The following example
  581. shows script statements to start an Xmodem download from ZiffNet.
  582.  
  583. R LIB
  584. S DOW CHKFRG.ZIP /PROTO:XMODEM^M
  585. R complete.
  586. D X C:\DL\CHKFRG.ZIP
  587. S ^M
  588.  
  589. CompuServe's B+ protocol should not be invoked with the D statement.
  590. The B+ invocation occurs automatically when the system is ready to send
  591. a file.  Use the R or the W command to wait for the invocation of the
  592. CompuServe B+ protocol.
  593. For example:
  594.  
  595. R LIB
  596. S DOW SLICE.ZIP /PROTO:B
  597. W 60
  598.  
  599. Command
  600.  
  601. P letter prompt_string
  602.  
  603. The P (Prompt and Reply) command displays the specified prompt string
  604. and loads the response into a variable designated by a single letter in
  605. the range from A to Z. Variables are referenced by placing a percent
  606. sign in front of the letter of each variable.
  607. For example:
  608.  
  609. P A Enter your name: 
  610. N ^M Your name is: %A^M
  611.  
  612.  
  613. Command
  614.  
  615. = letter [text]
  616.  
  617. The = (Equate) command assigns a text string to a script variable letter.
  618. When the text operand is omitted, BACKDOWN assigns a null string to the
  619. variable.
  620. For example:
  621.  
  622. = F ZCOPY.COM
  623.  
  624. Command
  625.  
  626. W nn
  627.  
  628. The W (Wait) command temporarily halts execution of the script for
  629. nn seconds. During this period of time, any arriving characters are
  630. displayed on BACKDOWN's pop-up screen.
  631. For example:
  632.  
  633. W 25
  634.  
  635. Command
  636.  
  637. E n
  638.  
  639. The E (Echo Control) command sets the display characteristics to
  640. n during script execution. These are the values of n:
  641.  
  642.     0 stops display of all data.
  643.  
  644.     1 displays only the data received by BACKDOWN. The host may
  645.         echo any data sent from BACKDOWN.
  646.  
  647.     2 displays only data sent by BACKDOWN. Received data is not displayed.
  648.  
  649.     3 displays data sent from and received by BACKDOWN. This may
  650.         result in characters appearing twice on the screen.
  651.  
  652. If no E command is specified, the value defaults to 1.
  653. For example:
  654.  
  655. E 3
  656.  
  657. Command:
  658.  
  659. G label
  660.  
  661. The G (Goto) command transfers control to the point in the script at
  662. which label is found. The transfer is an unconditional forward or
  663. backward jump.
  664. For example:
  665.  
  666. G GetLaserlst
  667.  
  668.  
  669. Command
  670.  
  671. :label
  672.  
  673. The :Label command marks a particular point in a script as the target
  674. for a G or a T command.
  675. For example:
  676.  
  677. :GetLaserlst
  678. S DOW LASERL.ZIP /PROTO:B
  679. W 15
  680.  
  681. Command:
  682.  
  683. ; comment
  684.  
  685. You can include documentation in your scripts by using comment statements.
  686. A comment statement contains a semicolon as the first character on the
  687. line.  Any text appearing after the semicolon is ignored by the compiler.
  688.  
  689. -----------------------------------------------------------------------------
  690.  
  691. SIDEBAR 2: BACKDOWN MESSAGES
  692.  
  693. by Bob Flanders
  694.  
  695. When two computers have to communicate across telephone lines, occasional
  696. errors are bound to occur. When this happens, BACKDOWN will notify you,
  697. either on the screen directly (if you're working interactively) or by
  698. popping up over your application.  Many of the messages the program sends
  699. depend on the specific protocol you have selected, so they are listed by
  700. protocol and followed by brief explanations.
  701.  
  702.  
  703. XMODEM: Timeout, protocol ended 
  704. B+: Timeout, protocol ended
  705. ASCII:  No Characters seen for 30 seconds, protocol ended
  706.  
  707. The download is canceled when the message above is displayed.
  708.  
  709. XMODEM: Too many errors, download cancelled 
  710. B+: Too many errors
  711.  
  712. As a transfer proceeds, BACKDOWN is constantly checking for errors.
  713. If too many errors occur in a row, the download is canceled.
  714.  
  715. B+: Receiving filename
  716.  
  717. The message showing the name of the file being received is displayed
  718. when a transfer begins with the CompuServe B+ protocol.
  719.  
  720. XMODEM: User cancelled download 
  721. B+: Download cancelled
  722.  
  723. If you press the End key during a transfer, BACKDOWN will display this
  724. message and attempt to end the transfer gracefully.
  725.  
  726. XMODEM: Sender cancelled download
  727.  
  728. If the service you are using stops the download, BACKDOWN tells you
  729. about it with this message.
  730.  
  731. XMODEM: Write error. Protocol aborted 
  732. B+: Aborted: write error
  733.  
  734. This error occurs if BACKDOWN is unable to write data to the file you
  735. have specified, as may happen, for example, if the disk fills up.
  736.  
  737. XMODEM: Packet sequence error
  738.  
  739. This is an unusual error in Xmodem where a piece of the file being
  740. transferred has been irrecoverably lost, so the transfer is canceled.
  741.  
  742. XMODEM: Download completed OK 
  743. B+: Download completed OK
  744.  
  745. This message appears after a successful download.
  746.  
  747. ----------------------------------------------------------------------------
  748.  
  749. ZIFFNET.BDS     COMPLETE LISTING
  750. 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.
  751.  
  752.  
  753.  
  754. ; Dial up Ziffnet and log in.
  755.  
  756. ; This script is designed to work with a modem using an AT-command set.
  757.  
  758. O 2400 8N1 7BIT B+ NOCASE
  759.  
  760. ; Init the modem
  761. T 5 ReInit
  762.  
  763. :Init
  764. S ATZ^M
  765. W 3
  766. S ATE0V1^M
  767. R OK
  768. G Dial
  769.  
  770. ; Only reaches here if first init fails
  771. :ReInit
  772. T 5 FailInit
  773. G Init
  774.  
  775. ; Die gracefully if modem does not respond
  776. :FailInit
  777. N Modem did not respond^M
  778. G End
  779.  
  780. ; Dial ZiffNet
  781. :Dial
  782. N ^MDialing ..
  783. T 60 NoAnswer
  784. W 1
  785. ; Replace "xxx-xxxx" with your local Compuserve telephone number
  786. S ATDTxxx-xxxx^M
  787. R CONNECT
  788. W 1
  789. N ^MConnected^m
  790. W 2
  791.  
  792. ; Send userid
  793.  
  794. S ^C
  795. R User ID:
  796. ; Replace "yyyyy,yyy" with your account number
  797. S yyyyy,yyy^M
  798.  
  799. ; Send Password
  800.  
  801. R Password:
  802. ; Replace "Your:password:Here" with your password
  803. S Your:password:Here^M
  804.  
  805. N ^M^G --- Login Complete --- ^G^M
  806. G End
  807.  
  808. : NoAnswer - Hangup and tell operator
  809. H
  810. N ^G -- Line busy or your modem isn't working -- ^G^M
  811.  
  812. : End
  813.  
  814. ; Recompile this script with the command BD /C ZIFFNET
  815.  
  816. ----------------------------------------------------------------------------
  817.  
  818. TESTPARM.BDS     COMPLETE LISTING
  819. 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.
  820.  
  821. If you have the following script called TESTPARM:
  822.  
  823. N Parm 1 is %1^M
  824. N Parm 2 is %2^M
  825. N Parm 3 is %3^M
  826.  
  827. Here is a sample execution:
  828.  
  829. Script name: TESTPARM Alpha Beta Gamma
  830.  
  831. Parm 1 is Alpha
  832. Parm 2 is Beta
  833. Parm 3 is Gamma
  834.  
  835. ----------------------------------------------------------------------------