background image

Summary of Contents for TRS-80 Model II

Page 1: ...Radio haeK O MMS MPonnsiR Owners Manual Programming Guide CUSTOM MANUFACTURED IN U S A BY RADIO SHACK A DIVISION OF TANDY CORPORATION...

Page 2: ...Important Notice Your computer must be off when you connect the disk interface Otherwise you could damage the system...

Page 3: ...OFTWARE SOLD LEASED LICENSED OR FURNISHED BY RADIO SHACK INCLUDING BUT NOT LIMITED TO ANY INTERRUPTION OF SERVICE LOSS OF BUSINESS OR ANTICIPATORY PROFITS OR CONSEQUENTIAL DAMAGES RESULTING FROM THE U...

Page 4: ...nal suggestions The user may find the following booklet prepared by the Federal Commu nications Commission helpful How to Identify and Resolve Radio TV Interference Problems This booklet is available...

Page 5: ...e ll just call it a disk It is far superior to tape the other alternative A disk is especially designed to file your infor mation so the Computer can immediately get the information you want For you t...

Page 6: ...I How about those of you who have never programmed and intend to use application programs written by Radio Shack or someone else You re the second group Read Chapter 1 To Get Started Then if you re in...

Page 7: ...Disk Program Chapter 81 How Much Can One Disk Hold 41 What the Computer Writes in a Disk File Chapter 91 Trimming the Fat Out of Direct Access 47 Formatting a Direct Access File Chapter 101 Shuffling...

Page 8: ......

Page 9: ...r to the T V If you haven t done it yet refer to the Color Computer Operation Manual A CONNECT DISK SYSTEM Your Disk System is easy to connect Do it before you turn on your Computer by simply plugging...

Page 10: ...the 26 3023 Drive to the inside plug Plug B If you have more 26 3023 Drives and an expanded cable connect these Drives to inside plugs also The 26 3029 Drive must be connected to the last plug in the...

Page 11: ...begin Begin what Well if you want to know how to take full advantage of your disk system we d like you to read Section I You ll find a lot of helpful information there If you re in a hurry to run you...

Page 12: ......

Page 13: ...ganized This makes disks easy to work with In this section we ll show you how your Computer organizes everything on your disk and how you can take advantage of this We invite all of you to read this s...

Page 14: ......

Page 15: ...dividing each track into sectors Then we re not finished yet each sector is divided into bytes and each byte is divided into bits Note To be precise there are 35 tracks on a disk 18 sectors in each tr...

Page 16: ...eformat a disk Thin common way to erase everything on it If you have more than one disk drive you can for mat a disk in one of the other drives by substitut ing the appropriate drive number for drive...

Page 17: ...tion This application program will get the Computer to put the infor mation you type into memory The important thing to remember about memory is that turning off your Computer erases it Once memory ha...

Page 18: ...H 10 PRINT CHANGED FILE ENTER SfliJE SIMPLE PRO ENTER FILENAMES You have already used one filename SIMPLE PRO If you did our memory vs disk storage exercise you ve used a second filename CHANGE We gav...

Page 19: ...y for the use of technical pro grammers Interested Then read on The third column lists the type of file it is BASIC program 1 data created by a BASIC program 2 data created by a machine language progr...

Page 20: ......

Page 21: ...r magnetic device such as your television set could completely rearrange its magnetic code Your information would be lost Heat and sunlight could have the same effect The same goes for turning your Co...

Page 22: ...rive If you have only one disk drive it will take you about five minutes to make a backup copy Insert your source disk in your disk drive and shut the DRIVE DOOR Type OIR ENTER to see which files you...

Page 23: ...le to do this by formatting it all over again as if it were a blank disk Although this might salvage the disk it will not salvage the contents of the disk By reformatting the disk you will erase every...

Page 24: ...sure there is a disk inserted properly in the indicated drive and the drive door is closed 2 If you still get this error there might be something wrong with your disk Try reinserting the disk first Th...

Page 25: ...ill seem as natural to you as protecting your papers from a strong gust of wind And once you get used to keeping your disk ungarbled you ll never want to go back to pencils and paper again we hope Z C...

Page 26: ......

Page 27: ...W NAM The program file has simply been renamed Everything else is the same RENAME is easy to use but there is one thing you need to remember Save a file without an exten sion and then try to rename it...

Page 28: ...FREE gran ules remaining on your disk There are 68 granules in all If the Computer tells you that you have only one granule FREE you d better do one of the following start using another disk or KILL...

Page 29: ...ge this assumption you can type DRIVE 1 CENTER This makes the Computer assume you want it to use DRIVE 1 unless you tell it otherwise After changing this DRIVE assumption the Com puter will respond di...

Page 30: ......

Page 31: ...refer to buy a ready made pro gram However if you want more control and are willing to invest a little time you will enjoy writing your own In this section we ll show you how to write a BASIC program...

Page 32: ......

Page 33: ...l summarize them now Everything you store on disk must go in a disk file and be assigned a filename Your Computer will index the location of the disk file in the disk s directory For example if you wa...

Page 34: ...buffer temporarily stores data so the Com puter can input and output data to the disk in Mocks of 249 characters I bytes Since buffer 1 only contains 8 characters DR HORN they would not be sent out t...

Page 35: ...et s combine them into one program Type 10 OPEN 0 i 1 i CHECKS DAT 20 WRITE 1 DR HORN 30 CLOSE 1 100 OPEN I t li CHECKS DAT 110 INPUT 1 A 120 PRINT A 130 CLOSE 1 Now add these lines and RUN the progra...

Page 36: ...and it ll soon be unbearable Here we have a tight program which asks you to INPUT all your data stores it on disk and reads it back into memory Erase memory and type 5 CLS 10 OPEN O 1 i CHECKS DAT 20...

Page 37: ...Try saving many different graphics programs on disk and calling them from one main program Sample Program 7 in Appendix C shows how...

Page 38: ...You can quickly store organize and update all your financial information with a disk system See Sample Program 1 2 and 8 in Appendix C for program listings...

Page 39: ...want to demonstrate how to change some of the data in your file Tb do this it is very helpful to use two buffers Note In Chapter 10 we ll demonstrate how to take advantage ofmore of these buffers Type...

Page 40: ...from buffer 1 Line 70 allows you to INPUT X which will replace A If you input X line 90 outputs it Line 90 outputs X to buffer 2 which in turn WRITEs it to NEW DAT Line 110 CLOSEs communication to bu...

Page 41: ...a small scale but how would it work in a large file What if you had 500 members in your MEMBERS DAT file and you wanted to change only the address of the 453rd member The process would still be the sa...

Page 42: ......

Page 43: ...in a sequential access file the Computer must start at the beginning and search through each item It can t go directly to the item In short a sequential access file does not take full advantage of yo...

Page 44: ...9 where we will demonstrate how to make smaller records PUTTING A RECORD ON DISK Enough theory Let s put one record in a disk file Since it ll be a direct access file we don t have to start with the...

Page 45: ...record 1 J DOE record 2 W MES DAT To PUT more records in the file add these lines Then RUN the program 31 WRITE 1 t BILL SMITH 32 PUT si a Now your NAMES DAT file will have these four records At this...

Page 46: ...es characters Since your empty records will contain garbage until you fill them with something it s a good idea to put some kind of data in all of them in advance Erase memory and type this program 10...

Page 47: ...sions when you will not know the last record number in the file Change line 60 and RUN the program G0 IF R L0F 1 THEN 90 LOF looks at the file which buffer 1 the number in parenthesis is communicating...

Page 48: ...7 3 CHAPTER CHECKPOINT 1 What are records Why must you use them to access data directly 2 What are Gelds 3 Whatis the difference between a sequential access and a direct access file 4 Why is it quick...

Page 49: ...nt to put more data on the disk You might also want to economize on memory space or use some extra buffer space At that time we invite all of you ambitious people to read this section The subject matt...

Page 50: ......

Page 51: ...s ters We call them granules Each granule con tains 2 304 bytes Because of this all of your disk files will contain a multiple of 2 304 bytes If your file contains 2 305 bytes of data for example the...

Page 52: ...e Computer actually WRITEs each ENTER character exactly as you typed it This illustration shows what Program 1 WRITEs on your disk We used asterisks to rep resent the ENTER characters of 0ffi dat 5 t...

Page 53: ...FILE CONTAINS 27 PRINT PRINT PRINT PRINT 30 IF EOFU 1 THEN 80 40 LINE INPUT 1 f L 57 M L G0 PRINT M G5 L LEN M L 70 GOTO 30 B0 CLOSE l 90 PRINT 394 L BYTES SAVE it It will be useful in comparing what...

Page 54: ...ING LESS You might feel that all the blank spaces PRINT inserts in your disk file are a waste of space They are The way to get around this waste is to use semi colons You might again recall from Getti...

Page 55: ...on there is not a deli meter a comma quotation mark or space to separate PEN from PAPER The line PRINT l JONES MARY would print this in your disk file 7 JONES t MARY The Computer would read JONES MARY...

Page 56: ...ccess files CHAPTER CHECKPOINT sen INPUT and IINT line cause i a PRINT tine IINT strings 10 OPEN I 1 20 IF EOFtl 1 30 LINE INPUT 1 40 PRINT At 50 GOTO 20 G0 CLOSE 1 1 What is the minimum size of a dis...

Page 57: ...CE DAT PROGRAM 5 512 bytes 10 OPEN D 20 WRITE 1 t 30 PUT 1 1 40 WRITE 1 50 PUT 1 i 2 60 CLOSE 1 It OFFICE DAT 5 PEN 16 PAPER A direct access program puts your data inside rec ords Each record is 256 b...

Page 58: ...s Program 5 except that we inserted a number 12 at the end of line 10 This tells the Computer to make each record 12 bytes long PROGRAM 6 24 bytes 10 OPEN B i lt OFFICE DAT 12 20 WRITE 1 t 5 PEN 30 PU...

Page 59: ...AS B 30 R R 1 m GET 1 R 50 PRINT RECORD R At Bt 60 IF LOF l R THEN 30 70 CLOSE 1 By using FIELD and LSET your program will work the same as any direct access program The difference is what FIELD and...

Page 60: ...m try writing your own FIELDed program PROGRAMMING EXERCISE 9 1 Write a direct access program to put a mailing list in a disk Hie Make each record 57 bytes with these six fields 1 last name 15 bytes 2...

Page 61: ...ICE DAT 10 20 FIELD i 5 AS A 5 AS B 50 PRINT RECORD R CYN A i B and RUN it CVN in line 50 decodes A to the number it represents Note The Computer only sees the first 9 digits of a number It rounds the...

Page 62: ......

Page 63: ...NVERSION TO MONTHS 20 N N 12 30 A STR N MONTHS S A U E MONTHS AGE A ENTER 10 REM AGE CONVERSION TO WEEKS 20 N N 52 30 A STRt N WEEKS Be sure to type the A when you SAVE these pro grams We ll explain w...

Page 64: ...are in binary codes Note Try typing MERGE MONTHS AGE ft HTFffi The R tells the Computer to RUN the program after it s MERGEd USING MORE BUFFER SPACE When you start up your disk system it sets aside t...

Page 65: ...s one more thing you ll like about FILES Erase memory type and RUN 10 CLEAR 100 20 files 1 am 30 A NORMALLY t YOU WILL NOT BE ABLE TO PUT ALL OF THESE SENTENCES IN A DISK FILE AT THE SAME TIME 10 B T...

Page 66: ......

Page 67: ...es on the disk into tracks and sectors Some of these bytes control the system The great major ity of them are for data TVacks The Computer organizes the disk into 35 tracks numbered 0 34 Each track co...

Page 68: ...ce each track contains two granules one granule is 2 304 bytes long 9 sectors in V2 track x 256 data bytes per sector 2 304 bytes in a granule The Computer uses granules to allocate space for disk fil...

Page 69: ...s will either contain a value of FF 0 43 or C0 C9 hexadecimal FF The corresponding granule is free It is not part of a disk file 00 43 The corresponding granule is part of a disk file The value conver...

Page 70: ...Programming by Lance Leventhal published by Osborne McGraw Hill for the spe cific 6809 instructions Information on DSKCON DSKCON s entry address is stored in locations C004 and C005 hexadecimal You c...

Page 71: ...REPORT THE ERRORS RTS LDA 45 STA aiD RTS E FOR ERROR TOP RIGHT OF THE DISPLAY C Note DSKCONpreserves the contents ofall registers except CC You can write a similar program to write to a sec tor by set...

Page 72: ...DSKI to search the directory for filenames with the extension DAT 10 FOR X 3 TO 11 20 DSKI 0 17 X A B 30 C A LEFT B 127 40 NAH 0 LEFT C 8 MID C 9 3 TO 7 MID C N 32 1 8 MID C 9 N 32 3 FOR N l 70 NAM N...

Page 73: ...AIPDPEMMIXEi...

Page 74: ...T 2 SEE THE FILE 40 PRINT 3 END 50 INPUT 01 60 ON 01 GOTO 80 130 420 70 GOTO 10 80 OPEN 0 tli MEMBERS DAT 90 1 OSUB 430 100 IF N THEN CLOSE 1 GOTO 10 110 WRITE 1 N A P 120 GOTO 90 130 OPEN I 1 MEMBERS...

Page 75: ...50 INPUT G0 INPUT 70 INPUT 80 INPUT 90 INPUT 100 INPUT 110 LSET LAST 120 LSET FIRST LAST NAME SL FIRST NAME iF ADDRESS A CITY iC STATE iS ZIP CODE iZ L F 140 LSET CITY C 150 LSET STATE S 160 LSET ZIP...

Page 76: ...procedure is repeated until the Com puter prints OK On a multi drive system type the BACKUP command specifying the drive number with the source disk and the destination disk For example BACKUP TO 1 b...

Page 77: ...ord length at 256 bytes 2 The data must have a field with a specific length for it to be LSET This length is assigned in the FIELD line 3 MKN converts a number into a 5 byte coded string CHAPTER 8 1 T...

Page 78: ...ALANCES 230 PRINT 3 322 3 END JOB 240 PRINT a 394 1 2 OR 3 250 AN INKEY 260 IF AN THEN 250 270 ON VAL AN GOSUB 310 700 1080 1560 280 GOTO 160 290 300 3 1 This s u b r o u t i n e inputs the data 320 3...

Page 79: ...ou created in Sample Program 1 and sorts all the checks by account Want to know exactly how much you spent on medical bills or business expenses contributions etc This pro gram will let you know right...

Page 80: ...OS The file is 35 bytes 80 lor 9 all of it allotted to one variab 1 e INFO The 90 file can be added to anytime a f t e r i t s c r e a t i o n a n d will 100 automatically be alphabetised The program...

Page 81: ...240 MID INT L0F l l 2 250 LAST LOF l 260 CNT 270 280 Program checks the last record first because it won t 290 be checked in the regular search 300 310 GET 1 LAST 320 IF NAME NM THEN 450 330 340 Prog...

Page 82: ...NUMBER PHONE 270 PRINT 3 228 EDIT THIS RECORD Y N 280 AN INKEY 290 IF AN Y THEN 320 300 IF AN N THEN 560 310 GOTO 280 320 PRINT 3 260 EDIT NAME Y N 330 AN INKEY 340 IF AN N THEN NM NAME GOTO 400 350...

Page 83: ...INT a 260 H 4 END 210 PRINT a 331 1 2 3 OR 4 220 AN INKEY 230 IF AN THEN 220 240 ON VAL AN GOSUB 290 430 640 1430 250 GOTO 130 260 270 This subroutine builds a NAMES file 280 290 OPEN 0 1 NAME FIL 300...

Page 84: ...ss 1170 1180 INPUT WHICH TEST NUMBER X 1190 CLS 1200 PRINT 3 4 DATA FOR TEST NUMBER X 1210 PRINT NAME STAB 25 SCORE 1220 TTOT 1230 FOR Y l TO YEND 1240 TTOT TTOT GRADED Y 1250 PRINT TABU NAME Y TAB 25...

Page 85: ...130 140 150 160 170 180 190 200 210 220 230 240 250 260 270 280 290 300 310 320 330 340 350 360 370 380 390 400 410 420 430 440 PMODE 3 1 SCREEN 1 0 DRAW BM104 60 D92 R48 U92 L48 DRAW BM44 20 R16B D1...

Page 86: ...ect of this program is to build three direct access 40 files one a listing of a balanced budget another a listing 50 of transactions and the third a listing of the updated 60 budget The program allows...

Page 87: ...LSET UPDAMT MKN AMT I 850 PUT 1 1 1 860 PUT 2 I 8 0 NEXT I 880 CLOSE 890 RETURN 900 910 This subroutine builds a transaction file called TFILE DAT 920 which contains anv updates to the budget and upd...

Page 88: ...B 10 ACCOUNT TAB 27 TRANSACTION 1610 PRINT 2 TAB 10 NUMBER TAB 14 DATE TAB 27 DESCR I PT I ON TAB 47 TRANSACTION TAB 61 BALANCE 1620 FOR 1 2 TO LOF l 1630 GET 1 I 1640 PRINT 2 1650 PRINT 2 TAB 12 ACN0...

Page 89: ...tation and the third converts the code to a hexadecimal Q6 based number Chapter 15 shows how to use these codes with CHR to produce a character CHARACTER DECIMAL CODE HEXADECIMAL CODE SPACEBAR CHARACT...

Page 90: ...ys simultaneously to get into an upper lower case mode The lower case letters will appear on your screen in reversed colors green with a black background CHARACTER DECIMAL CODE HEXADECIMAL CODE a 97 6...

Page 91: ...r of buffers set by FILES 1 x 281 bytes 4 BASIC Program Storage 5 BASIC Variable Storage 6 Stack 7 String Space 8 User Memory Extended COLOR BASIC ROM COLOR BASIC ROM COLOR DISK BASIC ROM Unused Space...

Page 92: ...5V4 mini diskettes Radio Shack Catalog Number 26 305 26 405 package of three or 26 406 package of 10 Single sided Double density 35 tracks 18 sectors per track 256 data bytes per sector Directory on t...

Page 93: ...s error if you do not specify a drive number when using DSKINI or BACKUP If you have only one drive specify drive with these two commands DSKINIO or BACKUP 0 Device Number error You are using more buf...

Page 94: ...as been used or reserved OS Out of String Space There is not enough space in memory to do your string operations Use CLEAR at the beginning of your program to reserve more string space OV Overflow The...

Page 95: ...DRIVE command number This may be a number 1 5 3 a numeric variable A BL a numeric function ABS 3 or a numeric operation 5 3 A 7 string This may be characters B STRING a string variable A BL a string...

Page 96: ...E 1 DSKINIdriue number 8 Formats a disk in the drive number you specify Executing this command will erase memory DSKINI0 DSKINI1 DSKI drive number track sector string variablel string variable2 61 62...

Page 97: ...filename you specify from the disk directory See the format for file names above You must include the extension with the filename KILL FILE BAS KILL FILE DAT 1 20 LINE INPUT buffer data Inputs a line...

Page 98: ...ice The buffers and the devices they communicate with are 33 38 screen or printer it is not necessary to open this buffer 1 tape recorder 2 printer 1 15 disk drive The communication modes you can use...

Page 99: ...sk to a new filename You must specify the extension ofboth filenames RENAME MFILE DAT 1 TO BFILE DAT 1 RSET field name data Right justifies the data within the field name you specify If the data is la...

Page 100: ...ll use drive or the drive number you specified with DRIVE UNLOAD UNLOAD VERIFY ON 15 VERIFY OFF Turns the verify function ON or OFF When VERIFY is ON the Computer will verify all disk writes WRITE buf...

Page 101: ...59 84 File number 84 FORMAT 7 8 47 FREE 86 GET 34 35 36 86 Granule 58 59 Hexadecimal 57 SUBJECT PAGES INPUT 26 27 34 36 37 42 43 61 86 Interface 2 KILL 20 86 LINE INPUT 42 43 86 LIST 9 LOAD 9 86 LOADM...

Page 102: ...INDEX SUBJECT PAGES Technical Information 57 62 Tracks 57 58 UNLOAD 13 89 VERIFYOFF 15 89 VERIFYON 15 89 WRITE 25 34 35 37 42 89 WRITE PROTECT 15 92...

Page 103: ...es the right to refuse to service the equipment or to void any remaining warranty on the equipment 2 If any Radio Shack computer equipment has been modified so that it is not within manufacturer s spe...

Page 104: ...RT WORTH TEXAS 76182 CANADA BARRIE ONTARIO L4M4W5 TANDY CORPORATION AUSTRAUA BELGIUM UNITED KINGDOM 91 KURRAJONG ROAD PARC INDUSTRIE NANINNE BILSTON ROAD WEDNESBURY MOUNT DRUITT N S W 2770 5140 NANINN...

Reviews: