ment of Education, 134 Cordell Hull Building, Nashville, TN 37219. differences in machine speeds when moving files from one brand of machine to a different ...
Behavior Research Methods. Instruments, & Computers 1985. /7 (3), 435-436
A generic BASIC program for data communications COLLIN T. BALLANCE, BILL WARD, and PATRICK SMITH Tennessee Department of Education, Nashville, Tennessee
A feature of the interpretive BASIC languages supplied on most microcomputers is that codes from several "BASICS" may be combined in the same program. When the executed code is correct and the code foreign to the interpreter being used is bypassed, problems do not occur. Thus, BASIC programs can be prepared which run on several different .machines. A front-end menu query is utilized to identify the brand of microcomputer on which the program is running. The source code (see Appendix) displays a hybrid BASIC program that has been used to transfer both text and BASIC programs among ffiM-PC, Radio Shack TRS80 Model ill, and Apple lIe microcomputers. Lines 240360 are consistent with the syntax rules for all three computers and present the menu through which the computer brand is identified. The user answers a query about whether to send or receive a file, and names the file to be accessed for transmission or the file to be received and stored. Lines 70-200 handle communications to and from the TRS-80 microcomputer, lines 370-610 control communications to and from the ffiM-PC, and lines 620-820 govern communications to and from the Apple lIe. If a machine other than one of the three listed is used, it may trap certain types of errors; that is, lines of code which will not run under the machine's interpreter may not be enterable from the keyboard. Should this situation arise, the user simply bypasses that line and continues to enter the remaining lines of program code. This is not a problem when the program executes because the unenterable lines would not have been executed on the machine. Communications from the sending to the receiving microcomputers are handled using standard asynchronous (RS-232)procedures. Our approach is to fit the microcomputers' serial communications ports with the appropriate vendor's RS-232 cables and then connect these cables using a modem eliminator. If the necessary cables are not readily available from the computer manufacturers, then substitutes as well as a modem eliminator may be purchased from a retail computer store or outlet. The demonstration program shown in the Appendix utilizes timing delays, set within the program, to mediate
Collin T. Ballance is a CDP and Director of Information Systems, Bill Ward is a CDP and Manager of Systems, and Patrick Smith is a Systems Analyst. Individuals requiring additional information may contact any of the authors at: Data Management Systems, Tennessee Department of Education, 134 Cordell Hull Building, Nashville, TN 37219.
differences in machine speeds when moving files from one brand of machine to a different brand of microcomputer. Because our intention was to create a generic communications program, the same software-set communications characteristics-asynchronous transmission, Ascn characters stored as text, 300 bits per second (bps), even parity, one stop, and seven data bits-are used for each microcomputer. As mentioned, standard RS-232 communications hardware and a model eliminator are utilized. The size of the transferred file is inconsequential, because the communications program calls for the receiving machine to write the captured file to disk rather than storing it in RAM. The order in which this program code is arranged reflects a need to minimize search time through the code as described in the IBM BASIC manual. Most lines of the program code are composed of multiple commands, which is unfortunate but necessary in order to increase the processing speed. A relatively slow transmission time is used because the process of capturing data and writing to disk can retard the procedure and cause character loss when different brands of microcomputers are paired for transmission and reception. Even though timing delays and a transmission rate of only 300 bps are employed, the user can move approximately 700 characters every 30 sec. Using the Sample Program. The source code listed in the Appendix allows the user to transfer files, including BASIC programs stored as ASCn, between ffiM, Radio Shack, and Apple microcomputers. Presumably, the transfer of files to or from other brands of microcomputers requires that the necessary code unique to those devices be inserted. Once the transfer has been effected, attention should be given to differences in the versions of BASIC used by the machines. Special attention is due cursor-locating instructions, which vary in the versions of BASIC used for most non-graphic programming. Graphics instructions used by these three microcomputers are incompatible. If all files and/or programs to be transferred are not in ASCn format, they must be converted. Conversion is easily accomplished on the ffiM-PC and TRS-80 by saving programs using the ASCn option. This option is not available on the Apple lIe. Our method of storing Apple program code is to LOAD the program and append the following statements at the beginning of the program: 1 D$-CHR$(4):PRINT D$: "OPEN HOLDAREA":PRINT D$;"WRITE HOLDAREA" 2 POKE 33,30:LIST 4,:PRINT D$;"CLOSE HOLDAREA" 3 TEXT: END (Obviously we assume that the first program line number is 4 or larger.) At this point, running the program causes it to be stored as an ASCII file called HOLDAREA.
435
Copyright 1985 Psychonomic Society, Inc.
436
BALLANCE, WARD, AND SMITH
After receiving a program stored as an ASCII text file on the IBM-PC or TRS-80, the user may LOAD and RUN it. If the program has been received by the Apple lIe, it remains in TEXT format and must be converted. The procedure is to clear memory by typing NEW, EXEC the name of the received program, and SAVE the program. Since the communications program assumes that ASCn code is being transferred, adjustments may be required for other types of files. To transfer sequential text, Line 550 is deleted and the ELSE condition removed from Line 360. When sending to an Apple lIe, lower case characters are converted to upper case if a 40-character screen is used. To use an 80-character screen, an Apple Super Serial Card must be installed and the following line must be inserted: 625 PRINT X$;"nS", where n is the slot housing the Super Serial Card. If the receiving machine does not accommodate certain ASCII codes, such as those for lower case characters, then the characters appear as garbage when received. The purpose of Line 550 is to delete a stray first character sometimes sent by the TRS-80 to the IBM-PC when transferring BASIC code. When transferring BASICcode to or from the IBM-PC, the BAS file extension should not be added. The program is designed to accomplish this for you. The user must wait until the light of the disk drive goes off before responding to the START OTHER MICRO message on the receiving microcomputer. Complications associated with the timing of the communications commands preclude the use of REMarks and other internal documenting information. Although REMark statements are supplied with the source code, these statements should be removed before running the program.
60
G01'O 2EtO
70 CLS:POItE lr.888.B~:PO~£. 16889.164:POr.E 16890.255 80 IF XVS·"s" THEil 170 90 ilE~ 100 ReM LINES lZO-lJO PERFORM DATA RECEPTIOII O. THE
Tl.S-80 110 REM 120 8$-·.. ·:OPElf "O".2.PII$:DEPOSlll-.H5A:Z-DSI.1{O):DEFOSRZ-6850:P1lIJIT "STAtT OTRER MICRO"
130 FOR II-I TO 2. STEP 0: X-USR.l{O):A$-CHR${PEEK.(l6872»: IF A$r.:$ ...ND A$R.$ THE N B$"'$+A$:NEXT ELSE IF A$4$ TUEN P.. IIIIT'2.B$:Pl.ltlTB$:BS ...... :JfE:lT ELSE CLOSE:END 140 REM 150 REM LINES 170-200 SEIID DATA FROM THE nS-80 160 REM 170 POltE 16930.ASC("P"):POK.E 16931.ASC(,"):POK.E 16928.ASC("'R"):POK.E t6929.ASC(" 0"): DEFUSRI .. &R6C:X-USR1(0):OPEIII "I".2.PII$ 180 LUll. INPUT#Z.A$:PaIRT A$:LPRHIT "$:'08. 1 .. 1 TO "iDO:.EXT I 190 IF EOF(2) THEN CLOSE: LP1lINT E$:EIIO 200 GOTO 180 210 REM 220 REM LINES 240-360 PROVIDE OPEIIIIIIC MEIIU (SEIID'"ECEIVE.BllAIID OF MICkO) 230 REM 240 FOR I-I TO 27:PRUI"T:NEXT:PRI.T" WBAT ...Allln OF MICl.O ""E 'rou OSItfG "":PRI NT
Z50 260 270 280 290 300 TER )10 )ZO 330 340 )50 360 370
380 390 400 410 420 430 440 450 460 470 460 490 500 510 520 530 540 550 560 570 580 590 600 610 620 630 640 650 660 670 680 690 700 710 720 730 740 750 760 770 780 790 800 810 820
PRINT" APPLE. RADIO s aacs; • IB.":,OI. 1...1 TO B:P11I1n:IlIEXT:IIlIPOT Z$ IF LEFT$(Z$.I) ...." .. OR LEPT${Z$.I)-...... at LEFT$(Z$.l)-"I" THE. 280 paINT" INV"LID ilESPONSE------REEllItER ": COTO 240 FOR I-I TO 6; pa. INT: NEXT: IF LEPT$(Z$.I ) " TBUI CLEA& 3000: Z$- -cIP LEPT$(Z$.I )-"1" THEil CLEAR 3000: 7.$ 1 .. ES .. CHJ.S(26}:R$-CRll.$(13):PRIliT "TO SElin A P110QAlI TO A.OTIlER Juao Ell S " PRINT "TO RtCtIVE A paOCR.AM OM ,\MOTRER nrcac It_TItR" .. FOR I-I TO 5: PR INT: NEXT: INPUT XV$ IF XV$"S" AND XV$