home *** CD-ROM | disk | FTP | other *** search
- 10 rem (c) 1988 uptime magazine
- 20 rem (c) 1988 softdisk publishing inc.
- 30 rem author: noel nyman
- 40 rem gray border, black screen, light green text
- 45 sys65409
- 50 poke53280,11:poke53281,0:poke646,13
- 60 rem q$=quotes, force upper/lower case, run/stop disabled
- 70 q$=chr$(34):printchr$(14)chr$(8):sp$=" ":poke808,234
- 80 rem --- sys (NULL),x,y places cursor at row x, column y ---
- 90 q=679:forx=qto706:reada:pokex,a:next
- 100 data 32,253,174,32,158,173,32,170,177,132,2,32,253,174,32,158
- 110 data 173,32,170,177,166,2,76,240,255,56,176,250
- 120 rem skip sub-routines
- 130 goto560
- 140 rem *** clear screen to line 23 starting at line 'x' ***
- 150 x=10:gosub160:sysq,10,3:return
- 160 fory=xto23:sysq,y,0:sys 59903:pokey+217,peek(y+217)or128:next
- 170 return
- 180 rem *** filter keyboard input for string ***
- 190 rem ---returns string in xx$ length 'll' or smaller---
- 200 xx$="":xb=65:xe=90:goto220:rem lower case alpha only
- 210 xx$="":xb=48:xe=57:goto220:rem numeric only
- 220 gosub270:xa=asc(cg$):ifxa=13andxx$<>""thenreturn
- 230 if(xa=20)and(xx$<>"")thenprintcg$;:xx$=left$(xx$,len(xx$)-1):goto220
- 240 if(xa<xb)or(xa>xe)goto220
- 250 iflen(xx$)>=llgoto220
- 260 printcg$;:xx$=xx$+cg$:goto220
- 270 xl%=peek(211)
- 280 if(xl%>39)thenxl%=xl%-40:goto280
- 290 xl%=xl%+peek(214)*40+1024:xc=54272+xl%
- 300 pokexc,peek(646):xo%=peek(xl%):xt%=xo%:xq%=128:if(xo%>127)thenxq%=-xq%
- 310 xt%=xt%+xq%:pokexl%,xt%:xq%=-xq%
- 320 forxr=1to60
- 330 getcg$:if(cg$<>"")thenpokexl%,xo%:xr=61:next:return
- 340 next:goto310
- 350 rem *** delay loop ***
- 360 rem --- enter with delay time in x ---
- 370 fora=1tox:next:return
- 380 fory=11to16:sysq,6,y:print"[158]->[153]":x=50:gosub370:next:return
- 390 gosub420:sysq,5,19:printsp$:sysq,6,19:printsp$:return
- 400 sysq,0,0:sys59903:return
- 410 fory=16to11step-1:sysq,6,y:print"<*":x=50:gosub370:next:return
- 420 sysq,6,11:print" ":return
- 430 rem *** prompt ***
- 440 sys679,24,1:print"[152][211][208][193][195][197] [194][193][210] to continue - [198]8 for [213][208][212][201][205][197][146][153]";
- 450 wait198,1:poke198,0
- 460 if(peek(631)=32)or(peek(631)=13)thenwait197,64:return
- 470 ifpeek(631)<>140goto450
- 480 rem re-enter uptime environment
- 490 printchr$(9): rem enable shift/c=
- 500 poke186,8: rem device #8
- 510 poke808,237: rem re-enable run-stop
- 520 load"reboot",8
- 530 rem ***************************
- 540 rem main program starts here
- 550 rem ***************************
- 560 print"[147]"
- 570 print"[158] [182][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][181]
- 580 [153]"sys abs print(NULL)(NULL)right$(NULL)chr$ (NULL)val(NULL)(NULL)val(NULL)(NULL)right$atn(NULL) ascright$(NULL)val(NULL) sysint
- 590 print" [182][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][181]
- 600 [153]"print# published by (NULL)oftdisk (NULL)ublishing
- 610 print" written for [213][208][212][201][205][197] by [206]oel [206]yman
- 620 [153]"print (NULL)n many disks, you've seen files in
- 630 print"the disk directory with [211][197][209][153] following
- 640 [153]"their names. sys(NULL)val(NULL)printuential files are often";
- 650 [153]"used by programmers to store data. They";
- 660 [153]"can also be used for word processor and
- 670 print"other text files.
- 680 [153]" (NULL)e're going to show you how to make
- 690 print"your own [158][211][197][209][153] files to hold data from
- 700 [153]"your programs, and how to read just
- 710 print"about any [158][211][197][209][153] file.":gosub440
- 720 print"[147]
- 730 [153]"lenomputer asciles str$isk asciles
- 740 print"[129][163][163][163][163][163][163][163][163][163][163][163][163][163][163] [163][163][163][163][163][163][163][163][163][163]
- 750 [153]"list10 8 2 1 "q$"(NULL)(NULL)(NULL)right$(NULL)val"q$" (NULL)(NULL)chr$
- 760 print" 4 4 0 15 "q$"[204][197][212][212][197][210]"q$" [211][197][209]
- 770 [153]"15 8 15 12 "q$"asc(NULL)(NULL)chr$chr$right$val"q$" (NULL)(NULL)chr$
- 780 print"[153] [213]nfortunately, the same word is often";
- 790 print"used in the computer world to mean two
- 800 [153]"different things. (NULL)he word "q$"file"q$"print has
- 810 print"two meanings for [195]ommodore computers.
- 820 [153]" (NULL)ou already know that a collection of";
- 830 [153]"data on a diskprint is known as a sysfileprint.
- 840 print" [212]he computer[153] also uses [158]files[153], but
- 850 [153]"for a different purpose.":[141]440
- 860 [153]"loadlist(NULL)(NULL)val(NULL) 4, 4, 0: len(NULL)str$ 4: (NULL)right$(NULL)(NULL)print
- 870 print" [217]ou may have used computer files
- 880 [153]"without knowing it. The set of commands";
- 890 [153]"above (NULL)right$(NULL)(NULL)prints a peekatn(NULL)right$len program to your":[153]"printer.
- 900 gosub440:sysq,1,8:print "^
- 910 [158]q,2,6:[153]"deviceprint":[141]150
- 920 [153]"(NULL)his is the device numberprint. (NULL)ost
- 930 print"[195]ommodore printers are [158]device #4[153].
- 940 [141]440:[158]q,1,8:[153]" ^
- 950 sysq,2,3:print"secondary address[153]":sysq,14,0
- 960 print" [212]his number is called the secondary
- 970 [153]"addressprint. (NULL)ome devices use this number
- 980 print"for special purposes. [193] secondary
- 990 [153]"address of syszeroprint puts lenommodore printers
- 1000 print"into [213]pper [195]ase/[199]raphics mode.
- 1010 [141]440:[158]q,1,5:[153]"^ ^
- 1020 sysq,2,1:print"file number file number[153]":sysq,21,3
- 1030 print"[212]his number is the file number[153].":gosub440
- 1040 print"[147][155][207][208][197][206][153]
- 1050 [158]59903:[153]" atn computer fileprint is the reference
- 1060 print"used by the machine and the programmer
- 1070 [153]"for input/output or sysright$/(NULL)print activity. (NULL)o
- 1080 print"communicate with a printer, modem, or
- 1090 [153]"disk drive, you must create or (NULL)(NULL)val(NULL)print a":[153]"file.
- 1100 print" [212]he computer keeps track of files by
- 1110 [153]"using the file numberprint. (NULL)his number
- 1120 print"can be any whole number from 1[153] through
- 1130 [153]"127print. ((NULL)he numbers sys128print through sys255print
- 1140 print"are used to add an extra blank line when";
- 1150 print"[158][204][201][211][212][153]ing programs to a printer.)
- 1160 [153]" (NULL)ow, enter a number between 1print and
- 1170 print"127[153] for a file number."
- 1180 print"---> ";:x$=""
- 1190 ll=3:gosub210:xx=val(xx$):if(xx>0)and(xx<128)goto1220
- 1200 print"[147][153][217]our number should be between [158]1[153]
- 1210 [153]"and sys127print. (NULL)ry again.":[137]1180
- 1220 fl$[178]xx$:[153]"loadlist(NULL)(NULL)val(NULL) "fl$"
- 1230 print"[153] [207]nce we set up or "q$"open"q$"[153] a file,
- 1240 [153]"we have to tell the computer which
- 1250 print"device we want to use with that file.
- 1260 [153]" (NULL)ince we're going to create a sys(NULL)val(NULL)print
- 1270 print"disk file, we'll use device #8[153].":gosub440
- 1280 print"[155]"tab(5+len(fl$))",8
- 1290 [141]150:[153]"printstr$on't forget the sys"q$","q$"print between the
- 1300 print"file number and the device number.":gosub440
- 1310 print "[147][155][207][208][197][206] "fl$",8"
- 1320 print"[147][155][207][208][197][206] "fl$",8":print"[153] [212]he [158]secondary address[153] you need to use";
- 1330 print"depends on the device. [208]rinters and
- 1340 [153]"printer interfaces use the secondary
- 1350 print"address to change printing styles.
- 1360 [153]" str$isk drives use the syssecondary addressprint";
- 1370 [153]"in the same way that the computer uses
- 1380 print"file numbers. [198]or a disk drive, the
- 1390 [153]"secondary address is often called a":[153]"channelprint.
- 1400 print" [215]hen you want to [204][207][193][196], [211][193][214][197], read
- 1410 [153]"from, or write to a file, the disk drive";
- 1420 [153]"keeps track of which file on the disk to";
- 1430 [153]"use by a channelprint number.":[141]440
- 1440 [153]"load(NULL)et's review for a moment.
- 1450 print"[215]hich answer is correct?
- 1460 [153]" atn) (NULL)he computer and the disk drive
- 1470 print" both use [158]file numbers[153] to keep
- 1480 [153]" track of right$/(NULL) information.
- 1490 print" [194]) [212]he computer and the disk drive
- 1500 [153]" both use syschannel numbersprint to
- 1510 print" keep track of [201]/[207] information.
- 1520 [153]" len) (NULL)he computer uses sysfile
- 1530 print" numbers[153] and the disk drive
- 1540 [153]" uses syschannel numbersprint.
- 1550 getcg$:ifcg$=""goto1550
- 1560 if(cg$="c")or(cg$="[195]")goto1690
- 1570 if(cg$<>"a")and(cg$<>"[193]")and(cg$<>"b")and(cg$<>"[194]")goto1550
- 1580 print"[147][211]orry, that's not right.
- 1590 [153]"(NULL)hink of the computer as a filing
- 1600 print"cabinet[153]. [201]magine many little manila
- 1610 [153]"file folders inside the cabinet, and
- 1620 print"each one has its own [158]number[153].
- 1630 [153]"(NULL)here's a cableprint connecting the disk
- 1640 print"drive to the computer, just like the
- 1650 [153]"cable connected to a tv set. (NULL)ou
- 1660 print"select [158]channels[153] on the tv, and the[160]
- 1670 [153]"disk drive uses syschannelsprint to keep track
- 1680 print"of files.":gosub440:goto1440
- 1690 print"[147][210][201][199][200][212]!":print"[212]here are sixteen possible channels
- 1700 [153]"for each disk drive. (NULL)hey are numbered
- 1710 print"0[153] through 15[153].
- 1720 [153]" lenhannel (NULL)urpose
- 1730 print" [129][163][163][163][163][163][163][163] [163][163][163][163][163][163][163]
- 1740 [153]"print 0 sys(NULL)(NULL)atnstr$print only
- 1750 print" 1 [158][211][193][214][197][153] only
- 1760 [153]" 2 available
- 1770 print" 3 available
- 1780 [153]" : available
- 1790 print" : available
- 1800 [153]" 14 available
- 1810 print" 15 [158]commands[153] only";
- 1820 print" [206]ow, pick a channel number to use
- 1830 [158]q,24,0:[153]"---> ";:[158]q,24,5
- 1840 ll[178]2:[141]210:[139]([197](xx$)[177]1)[175]([197](xx$)[179]15)[137]2010
- 1850 [139][197](xx$)[177]15[137]1830
- 1860 [139][197](xx$)[177]0[137]1920
- 1870 [153]"loadprintlenhannel 0print is used by the sysstr$(NULL)(NULL)print, (str$isk
- 1880 print"[207]perating [211]ystem) to [204][207][193][196] programs or
- 1890 [153]"the disk directory into the computer.
- 1900 print"[217]ou can't use it to create or read":print"[158][211][197][209][153] files.
- 1910 [141]440:[153]"load":[137]1690
- 1920 [139][197](xx$)[177]1[137]1960
- 1930 [153]"loadprintlenhannel 1print is used by the sysstr$(NULL)(NULL)print, (str$isk
- 1940 print"[207]perating [211]ystem) to [211][193][214][197] programs":print"from the computer.
- 1950 [153]"(NULL)ou can't use it to create or read":[153]"sys(NULL)val(NULL)print files.":[137]1910
- 1960 [153]"loadprintlenhannel 15print is used by the sysstr$(NULL)(NULL)print, (str$isk
- 1970 print"[207]perating [211]ystem) for receiving
- 1980 [153]"commands and sending information
- 1990 print"on disk drive errors to the computer.
- 2000 [153]"(NULL)ou can't use it to create or read":[153]"sys(NULL)val(NULL)print files.":[137]1910
- 2010 sa$[178]xx$:[153]"loadlist(NULL)(NULL)val(NULL) "fl$",8,"sa$
- 2020 [153]"print left$ere's what the sys(NULL)(NULL)val(NULL)print command looks":[153]"like so far.
- 2030 print" [215]e've told the computer to [207][208][197][206] file
- 2040 [153]"#"fl$"print and place in it the fact that
- 2050 print"we're going to use channel #"sa$"[153] on disk":print"device #8[153].
- 2060 [153]" (NULL)ext, we need a name for the disk
- 2070 print"file we're going to create.":print"[197]nter a disk file name: ";
- 2080 ll=16:gosub200:df$=xx$
- 2090 print"[147][155][207][208][197][206]"fl$",8,"sa$","q$df$q$
- 2100 print"[153] [212]o give the disk drive the disk
- 2110 [153]"file name, we just add it to the (NULL)(NULL)val(NULL)
- 2120 print"command. [196]on't forget the [158]"q$","q$"[153] after":print"the secondary address.
- 2130 [153]" (NULL)ow we need to tell the disk drive
- 2140 print"that this is to be a sequential file.
- 2150 [141]440:[129]x[178]1029[164]1060:[139][194](x)[178]32[167]p[178]x:x[178]2000
- 2160 [130]:p[178]p[171]1025:[158]q,0,p:[153]"sys,s"q$
- 2170 [158]q,11,3:[153]"print(NULL)he sys,sprint tells the disk drive to create";
- 2180 [153]"a sys(NULL)val(NULL)printuential file. (NULL)ote that the sys,s
- 2190 print"[205][213][211][212][153] be [201][206][211][201][196][197] the quote marks.
- 2200 [153]" (NULL)ext, we have to tell the disk drive
- 2210 print"that we want to "q$"write to"q$"[153] the file,
- 2220 [153]"not "q$"read from"q$" it.
- 2230 gosub440:sysq,0,p:print"[155],s[158],w"q$
- 2240 sysq,19,3:print"[153][212]he [158],w[153] tells the disk drive to
- 2250 [153]"writeprint to the new file.":[141]440
- 2260 [153]"loadprint":[153]" thentab(tab(tab(tab(tab(tab(tab(tab(fn thentab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(tab(fn
- 2270 print" [167] [152][195]ptr[153] [165] [167] [154][196]isk [196]rive[153] ( ) [165]
- 2280 [153]" thentotototototototofn thentototototototototototototototototototofn
- 2290 print" [167] [165] [167] [165]
- 2300 [153]" then - - fn then fn
- 2310 print" [167][164][164][164][164][164][164][164][164][165] [167][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][164][180]
- 2320 [153]" printleft$ere's what happens when you use the":[153]"(NULL)(NULL)val(NULL) command.":[141]440
- 2330 [153]"list(NULL)(NULL)val(NULL) "fl$"print
- 2340 sysq,13,3:print"[212]he computer looks through its list"
- 2350 print"of open files for one named [158]"q$fl$q$"[153].
- 2360 [153]" right$f it doesn't find one, it makes one.":[141]440
- 2370 [158]q,6,5[171][195](fl$):[153]""fl$"print":[141]440
- 2380 [158]q,18,3:[153]"right$f it finds a file with that number,
- 2390 print"it prints [158]"q$"[198][201][204][197] [207][208][197][206] [197][210][210][207][210]"q$"[153] and your
- 2400 [153]"peekatn(NULL)right$len program stops. right$f you try to open";
- 2410 [153]"more than 10print files, you'll get a
- 2420 print"[158]"q$"[212][207][207] [205][193][206][217] [198][201][204][197][211] [197][210][210][207][210]"q$"[153].":gosub440:gosub150
- 2430 print""tab(5+len(fl$))"[155],8,"sa$"[153]"
- 2440 gosub150:print"[206]ext, the device number and the
- 2450 [153]"secondary address are added to the file":[153]"information.
- 2460 gosub440:sysq,6,6:print"8"sa$"[153]":gosub440
- 2470 print"[155][207][208][197][206] "fl$",8,"sa$","q$df$",s,w"q$"[153]
- 2480 [158]q,14,3:[153]"(NULL)nce the computer file is open, the
- 2490 print"channel number and file name are sent":print"to the disk drive.":gosub440
- 2500 gosub380:sysq,5,19:print""sa$"-"df$
- 2510 sysq,6,25:print"[150]s,w":gosub440:print"
- 2520 [158]q,18,3:[153]"(NULL)he disk drive checks to see if a
- 2530 print"file with the same name is already on
- 2540 [153]"the disk. right$t also makes sure that theclose
- 2550 print"channel is unused, and a [158]"q$"buffer"q$
- 2560 print"[153]is available to handle the file.":gosub440:gosub150
- 2570 print"[201]f an "q$"error"q$" occurs, the disk
- 2580 [153]"drive activity light begins to flash.":[141]440:[158]q,13,3
- 2590 [153]"right$f there's no error, the activity
- 2600 print"light comes on and stays on to indicate":print"an open file on the drive.
- 2610 [158]q,3,35:[153]"def*":[151]198,0
- 2620 [141]440:[141]400:[141]390:[141]150
- 2630 [153]"(NULL)ow we're ready to store some data
- 2640 print"in the sequential disk file. [215]e'll use
- 2650 [153]"three stringsprint of characters.
- 2660 print" [197]nter up to 12 alpha
- 2670 [153]"characters --->";:ll[178]12:[141]200:a$[178]xx$:[153]
- 2680 [153]"print (NULL)e'll put this text in atn$print.":[141]440
- 2690 [141]400:[153]"atn$="a$:[141]440:[141]150
- 2700 [158]q,10,3:[153]"printvalnter up to 12 alpha characters
- 2710 print"for [194]$[153] --->";:ll=12:gosub200:b$=xx$
- 2720 gosub400:print"[194]$="b$:gosub440
- 2730 sysq,14,3:print"[153][193]nd last, enter up to 12 characters
- 2740 [153]"for len$print --->";:ll[178]12:[141]200:c$[178]xx$
- 2750 [141]400:[153]"len$="c$:[141]440:[141]150
- 2760 [141]400:[153]"(NULL)(NULL)right$(NULL)(NULL)#print":[158]q,10,3
- 2770 [153]"print(NULL)o send information to the sequential";
- 2780 [153]"file, we use the sys(NULL)(NULL)right$(NULL)(NULL)#print command.
- 2790 print" [196]o [206][207][212][153] leave a space between the
- 2800 [153]"sys(NULL)(NULL)right$(NULL)(NULL)print and the sys#print! right$t's all one "q$"word"q$".
- 2810 print" [201]t will be easier to remember this
- 2820 [153]"command if you say "q$"(NULL)(NULL)right$(NULL)(NULL) ascright$(NULL)val"q$"print when
- 2830 print"you use it, because that's what it does.";
- 2840 print" [201]t prints[153] to an open file[153].":gosub440
- 2850 sysq,0,0:sys59903:gosub150
- 2860 print"[198]irst, we'll send the data in [158][193]$[153] to
- 2870 [153]"the sequential file.":x[178]500:[141]370
- 2880 [153]"(NULL)(NULL)right$(NULL)(NULL)#"fl$", atn$":[141]380
- 2890 [158]q,5,19:[153]" "a$"print":x[178]1000:[141]370
- 2900 [158]q,13,3:[153]"(NULL)he disk drive places "a$
- 2910 [153]"printin the buffer it assigned to the file.":[141]440:[141]390
- 2920 [158]q,16,3:[153]"(NULL)ext, we'll send the data in syspeek$print.
- 2930 print"[208][210][201][206][212]#"fl$", [194]$":gosub440:gosub380
- 2940 sysq,5,19:print" "b$"[153]":gosub440
- 2950 sysq,18,3:print"[212]he data goes into the same buffer.
- 2960 [153]" atn syslenleft$(NULL)$(13)print (the code for sys<(NULL)val(NULL)(NULL)(NULL)(NULL)>print) is";
- 2970 [153]"placed in the buffer after "a$
- 2980 [153]"printseparating it from "b$"print.":[141]440:[141]390
- 2990 [153]"(NULL)(NULL)right$(NULL)(NULL)#"fl$", len$ print":[141]150
- 3000 [153]"(NULL)ast, we'll send the data in syslen$print.":[141]440:[141]380
- 3010 [158]q,5,19:[153]" "c$"print":[141]440:[141]390:[141]400
- 3020 [158]q,12,3:[153]"(NULL)ow all the data has been sent to
- 3030 print"the disk drive. [212]he last of the data
- 3040 [153]"is still in the sysbufferprint. right$t hasn't been
- 3050 print"stored to disk yet. [215]e can see that,
- 3060 [153]"because the activity light on the drive":[153]"is still lit.
- 3070 print" [212]he [195][204][207][211][197][153] command is used to tell
- 3080 [153]"the computer and the disk drive that
- 3090 print"we're finished with the file.":gosub440:gosub150
- 3100 print"[195][204][207][211][197] "fl$"[153]":gosub380:sysq,10,3
- 3110 print"[193]ny data still in the [158]buffer[153] is":print"written to the disk.
- 3120 [153]" (NULL)hen that's done, the activity light
- 3130 print"goes off.":gosub440:sysq,3,35:print" ":gosub390:sysq,16,3
- 3140 print"[204]ast, the computer [195][204][207][211][197]s[153] the file in";
- 3150 print"the file table, freeing the space for a":print"new file.":gosub440
- 3160 sysq,6,2:print" - - ":gosub400
- 3170 sysq,19,3:print"[193]nd, we're done!":gosub440:gosub150
- 3180 print"[217]ou can send [158]numeric[153] as well as
- 3190 [153]"sysstringprint variables. ascor example:
- 3200 print"[208][210][201][206][212]#"fl$", [218] [153](floating point)
- 3210 [153]"(NULL)(NULL)right$(NULL)(NULL)#"fl$", (NULL)% print(integer)
- 3220 print"[208][210][201][206][212]#"fl$", "q$"[200]i"q$" [153](literal)":gosub440:gosub150
- 3230 print"[212]he data you've stored could be names[153]";
- 3240 print"and addresses[153] for a database. [201]t might
- 3250 [153]"be your deflocationprint in a maze game, so you
- 3260 print"can start from the same place again.
- 3270 [153]" (NULL)r, it might be the sysnumbersprint from a
- 3280 print"checkbook balancing program.
- 3290 [153]" right$n any case, the data is only useful
- 3300 print"to you if you can [158]read[153] it back into
- 3310 [153]"your program.":[141]440:[141]150
- 3320 [153]"(NULL)valatnstr$printing a sys(NULL)val(NULL)print file is almost the same";
- 3330 [153]"as creating one.
- 3340 print" [215]e [207][208][197][206][153] a computer [158]file[153], and specify"
- 3350 print"the [158]device[153] and [158]secondary[153] adrress.":gosub440
- 3360 print"[155][207][208][197][206] "fl$",8,"sa$","q$df$q$"[157][158],s,r"q$
- 3370 sysq,6,5-len(fl$):print""fl$"[153]-8[153]-"sa$:sysq,16,3
- 3380 print"[153][215]e'll use the same file and channel"
- 3390 print"numbers. [217]ou could use different ones.
- 3400 [153]" (NULL)otice that this time we use a sys,rprint
- 3410 print"for [158][210][197][193][196][153] instead of a [158],w[153] after the":print"file name.":gosub440
- 3420 gosub150:print"[212]he [207][208][197][206][153] command causes the disk
- 3430 [153]"drive to check the directory for the
- 3440 print"named file. [201]f found, it [158][207][208][197][206][153]s the
- 3450 [153]"file for sysreadprinting, and turns on the
- 3460 print"activity light.":gosub380:sysq,5,19:print""sa$"-"df$:sysq,6,25
- 3470 print"[150]s,r":sysq,3,35:print"[150]*":gosub440:gosub400:print"[201][206][208][213][212]#"fl$",
- 3480 [141]390:[158]q,16,3:[153]"print(NULL)o read the data, we use right$(NULL)(NULL)(NULL)(NULL)#print. atns
- 3490 print"with [158][208][210][201][206][212]#[153], there's no space between
- 3500 [153]"right$(NULL)(NULL)(NULL)(NULL)print and #print. (NULL)hinksys "q$"input file"q$"printwhen
- 3510 print"you use the command.":gosub440:print"[201][206][208][213][212]#"fl$", [193]$":gosub150
- 3520 print"[153][212]o read the data successfully, you
- 3530 [153]"must know the systypeprint, defsequenceprint, and sysnumberprint";
- 3540 [153]"of variables stored in the file.
- 3550 print" [201]f you try to read a [158]string[153] into
- 3560 [153]"numeric variable, such as atnprint, you'll
- 3570 print"you'll get a [150][212][217][208][197] [205][201][211][205][193][212][195][200][153] error from
- 3580 [153]"peekatn(NULL)right$len.":[153]" (NULL)ince we know that we've stored
- 3590 print"a [158]string[153] as the first variable, we'll
- 3600 [153]"use atn$print as the variable name for the
- 3610 print"[158][201][206][208][213][212]#[153] command.":gosub440:gosub150
- 3620 print"[215]hen the disk drive receives the
- 3630 [153]"sysright$(NULL)(NULL)(NULL)(NULL)#print command, it reads the data in the";
- 3640 [153]"file up to the syslenleft$(NULL)$(13)print, and sends
- 3650 print"it to the computer.":gosub440:gosub380:sysq,5,19:print""a$:gosub420
- 3660 gosub410:print"[201][206][208][213][212]#"fl$", [193]$ [158] <-- [193]$="a$:gosub440:gosub390:sysq,15,3
- 3670 print"[153][217]our program can now use the value
- 3680 [153]"in atn$print in any way you choose.":[141]440:[141]400:[141]150
- 3690 [153]"(NULL)e get the two remaining strings in
- 3700 print"the same way. [206]ote that the [158]name[153] of
- 3710 [153]"the variable doesn't matter, as long as
- 3720 print"the type[153] is correct.":gosub440:print"[201][206][208][213][212]#"fl$", [216]$":gosub380:gosub390
- 3730 sysq,5,19:print""b$:gosub410:print"[201][206][208][213][212]#"fl$", [216]$ [158] <-- [216]$="b$:gosub440
- 3740 gosub400:print"[201][206][208][213][212]#"fl$", [209][209]$":gosub380:gosub390
- 3750 sysq,5,19:print""c$:gosub410:print"[201][206][208][213][212]#"fl$", [209][209]$ [158] <-- [209][209]$="c$:gosub440
- 3760 gosub400:gosub390:print"[195][204][207][211][197] "fl$:sysq,15,3
- 3770 print"[153][212]he [158][195][204][207][211][197][153] command closes the file
- 3780 [153]"on the disk drive and removes the
- 3790 print"computer file from the file table.":gosub440:gosub380:sysq,3,35:print" "
- 3800 x=500:gosub370:gosub390:sysq,6,2:print" - - ":gosub400:gosub440
- 3810 gosub400:gosub150:print"[153][207]ne possible problem with using
- 3820 [153]"sysright$(NULL)(NULL)(NULL)(NULL)#print is the deflengthprint of strings that
- 3830 print"may be stored on the disk. [211]trings can
- 3840 [153]"be up to 255print characters long.
- 3850 print" [217]ou [158]concatenate[153] or [150]add[153] strings
- 3860 [153]"together to get longer strings.":[153]"(NULL)$=atn$+peek$+len$+str$$: (NULL)(NULL)right$(NULL)(NULL)#"fl$", (NULL)$
- 3870 gosub440:sysq,20,3:print"[153][201]f [158][193]$[153], [158][194]$[153], [158][195]$[153], and [158][196]$[153] are each
- 3880 [153]"60print characters long, sys(NULL)$print will have a
- 3890 print"length of [150]240[153]!":gosub440:gosub150
- 3900 print"[158][201][206][208][213][212]#[153] has a limit of 80[153] characters.
- 3910 [153]"(NULL)hat's because the computer reads the
- 3920 print"data from the disk into the same memory
- 3930 [153]"area that's used for screenprint input.
- 3940 print" [212]his memory area, or [158]buffer[153] holds
- 3950 [153]"only 80print characters, since that's the
- 3955 print"maximum size of a [150][195]64[153] screen line.
- 3960 [153]"((NULL)r 160print characters on a deflen128print).":[141]440:[158]q,19,3
- 3970 [153]"(NULL)o, how do we sysreadprint a file if we
- 3980 print"don't know how big the strings are, or
- 3990 [153]"how sysmanyprint there are?":[141]440:[153]"chr$val(NULL)#"fl$:[141]150
- 4000 [153]"print(NULL)e use the chr$val(NULL)#print (sysget fileprint) command.
- 4010 print" [201]t's similar to [158][201][206][208][213][212]#[153] because it
- 4020 [153]"retrieves data from an open sysfileprint.
- 4030 print" [201]t's also similar to [150][199][197][212][153], because it
- 4040 [153]"retrieves only defoneprint character at a time.":[141]440:[141]150
- 4050 [153]"chr$val(NULL)#print should only be used with a
- 4060 print"[158]string[153] variable name.":print" [212]o make a [158]string[153] in computer
- 4070 [153]"memory using chr$val(NULL)#print, you have to defassembleprint
- 4080 print"the string character by character.":gosub440:gosub400
- 4090 sysq,6,5-len(fl$):print""fl$"8"sa$
- 4100 gosub150:print"[157][157][157]100 [216][216]$="q$q$": [150][210][197][205] [195][204][197][193][210] [216][216]$
- 4110 [153]"110 chr$val(NULL)#"fl$", atn$: (NULL)=(NULL)(NULL)
- 4120 print"120 [201][198] [193]$="q$q$" [212][200][197][206] [193]$=[195][200][210]$(0)
- 4130 [153]"130 right$asc atn$=lenleft$(NULL)$(13) chr$(NULL)(NULL)(NULL) 200
- 4140 print"140 [216][216]$=[216][216]$+[193]$
- 4150 [153]"150 right$asc (NULL)=0 chr$(NULL)(NULL)(NULL) 110
- 4160 print"200 [150][210][197][205] [208][210][207][199][210][193][205] [195][207][206][212][201][206][213][197][211]
- 4170 [153]" printleft$ere's a program that defassembles
- 4180 print"[216][216]$[153] from a disk data file. [204]et's see
- 4190 [153]"how it works.":[141]440:x[178]18:[141]160
- 4200 [153]"start --> (NULL)(NULL)$="q$q$" sys(null)print":[158]q,18,3
- 4210 [153]" (NULL)ine 100print clears (NULL)(NULL)$print by making it
- 4220 print"[158]null[153], equal to nothing."
- 4230 print" [212]hen we start reading the information";
- 4240 print"on the disk drive.":sysq,5,19:print"[213][208][212][201][205][197][158]r[146]"
- 4250 sysq,6,25:print"[158]^[164][164][195][200][210]$(13)":gosub440:x=18:gosub160:sysq,18,3
- 4260 print"[212]he string in this disk file is the
- 4270 [153]"name (NULL)(NULL)(NULL)right$(NULL)valprint followed by the sys<(NULL)val(NULL)(NULL)(NULL)(NULL)>print
- 4280 print"character.":print" [204]ine 110[153] [150]get[153]s the first character
- 4290 [153]"and puts it in the variable atn$print.":[141]440:[141]380:[141]420:[141]410
- 4300 [153]"pass 1 -> (NULL)(NULL)$="q$q$;:[153]" sys(atn$=(NULL))":[158]q,5,19:[153]" ":[141]440
- 4310 [141]420:x[178]18:[141]160:[158]q,18,3:[153]"print(NULL)ine 110print also sets the variable sys(NULL)"
- 4320 [153]"printequal to the reserved variable sys(NULL)(NULL)print.
- 4330 print" [215]e'll see what that does in a moment.":gosub440:x=18:gosub160
- 4340 sysq,18,3:print"[204]ine 120[153] checks for a [150]bug[153] in the [158][199][197][212]#[153]";
- 4350 print"command. [201]f the character in the file
- 4360 [153]"is a defbinaryprint zero (not the sysatn(NULL)lenright$right$print
- 4370 print"character 0[153]), [158][199][197][212]#[153] returns a null":print"string.":gosub440:x=18:gosub160
- 4380 sysq,18,3:print"[211]o, we test for the null string, and
- 4390 [153]"if we find one, change it to syslenleft$(NULL)$(0)print.":[141]440:x[178]18:[141]160
- 4400 [158]q,18,3:[153]"(NULL)ine 130print checks to see if we're at
- 4410 print"the end of the string, [158][193]$=[195][200][210]$(13)[153]. [201]f
- 4420 [153]"we are, (NULL)(NULL)$print is complete, and we go on
- 4430 print"with the program.":gosub440:x=18:gosub160:sysq,18,3
- 4440 print"[204]ine 140[153] adds the value in [158][193]$[153] to
- 4450 [153]"(NULL)(NULL)$print.":[141]440
- 4460 [153]"pass 1 -> (NULL)(NULL)$="q$"(NULL)"q$;:[153]" sys(atn$=(NULL))":[158]q,5,19:[153]" ":[141]440
- 4470 x[178]18:[141]160:[158]q,18,3:[153]"(NULL)(NULL)print is a special variable reserved by
- 4480 print"[194][193][211][201][195] to hold information about [158][201]/[207][153] or
- 4490 [153]"input/output activity. (NULL)hile we're
- 4500 print"successfully reading through a disk file";
- 4510 print"[211][212][153] will have a value of [158]zero[153].":gosub440
- 4520 x=18:gosub160:sysq,18,3:print"[193]s soon as we read the last character";
- 4530 print"in the file, [211][212][153] changes its value to
- 4540 [153]"sys64print. (NULL)ine 150print checks variable (NULL)print, which
- 4550 print"we've set equal to [211][212][153]. [201]f it's still
- 4560 [153]"syszeroprint, we're not at the end of the file.":[141]440:x[178]18:[141]160
- 4570 [158]q,18,3:[153]"(NULL)ow we'll syschr$val(NULL)#print the rest of the":[153]"string.":[141]440
- 4580 [131] "(NULL)","(NULL)(NULL)","(NULL)","(NULL)(NULL)(NULL)","right$","(NULL)(NULL)(NULL)right$","(NULL)","(NULL)(NULL)(NULL)right$(NULL)","val","(NULL)(NULL)(NULL)right$(NULL)val"
- 4590 [129]z[178]2[164]6:[141]380:[141]420:[141]410
- 4600 [135]z$,zz$:[153]"pass"z"-> (NULL)(NULL)$="q$zz$q$;
- 4610 [153]" sys(atn$="z$")":[158]q,5,18[170]z:[153]" ":[141]420:x[178]700:[141]370:[130]
- 4620 [141]380:[141]420
- 4630 [141]410:[153]"pass 7 -> (NULL)(NULL)$="q$zz$q$;:[153]" sys(atn$=lenleft$(NULL)$(13))":[141]390:[141]440
- 4640 [141]400:[141]150:[153]"(NULL)ou can use syschr$val(NULL)#print and sys(NULL)(NULL)print to read and
- 4650 print"print to the screen any sequential file:":print"250 [199][197][212]#101,[193]$
- 4660 [153]"260 (NULL)(NULL)right$(NULL)(NULL) atn$; print<--don't forget the sys;
- 4670 print"270 [201][198] [211][212]=0 [199][207][212][207] 250":gosub440
- 4680 print"[147][153] [211]o far we've assumed that there were
- 4690 [153]"no sysdisk errorsprint as we worked with files.
- 4700 print" [201]n the real world, things won't be
- 4710 [153]"quite so error free. (NULL)ou may get a
- 4720 print"[158][198][201][204][197] [206][207][212] [198][207][213][206][196][153] or [158][196][210][201][214][197] [206][207][212] [210][197][193][196][217][153]
- 4730 [153]"error.":[153]" (NULL)he disk drive sends error messages
- 4740 print"in this format:":print"62 [198][201][204][197] [206][207][212] [198][207][213][206][196] 18 00"
- 4750 print "[153] [212]he [158]"q$"62"q$"[153] is the [150]error number[153]. [217]ou'll";
- 4760 print"find the possible error numbers listed
- 4770 [153]"in your disk drive manual. (NULL)he number
- 4780 print"is followed by a [158]string[153] that describes
- 4790 [153]"the error.":[153]" (NULL)he last two numbers are the track
- 4800 print"and sector numbers where the [158]error[153]
- 4810 [153]"occured.":[141]440:[153]"load (NULL)ou should always check for errors
- 4820 print"when working with disk files. [212]o do
- 4830 [153]"that, sys(NULL)(NULL)val(NULL)print a file to the syscommand
- 4840 print"channel[153] on the disk drive [194][197][198][207][210][197][153] you
- 4850 [153]"(NULL)(NULL)val(NULL) defanyprint other files!":[153]"100 (NULL)(NULL)val(NULL) 15,8,15
- 4860 print"[153] [208]rogrammers usually use [158]computer
- 4870 [153]"file #15print. (NULL)ou mustprint use sysdisk channel
- 4880 print"#15[153], the command channel.":print" [212]hen, after you [207][208][197][206] a file, read
- 4890 [153]"the command channel:":[153]"150 right$(NULL)(NULL)(NULL)(NULL)#15, (NULL), (NULL)$"
- 4900 [153]"160 right$asc (NULL)>19 (NULL)left$val(NULL) (NULL)(NULL)right$(NULL)(NULL) (NULL)$: len(NULL)(NULL)(NULL)val15: val(NULL)str$":[141]440:[158]q,18,3
- 4910 [153]"str$isk errors start with sys20print, so any
- 4920 print"number less than [158]20[153] means it's all
- 4930 [153]"right to continue. (NULL)hen you end your
- 4940 print"program, [158][195][204][207][211][197] 15[153] last, since closing
- 4950 [153]"the command channel closes all others.":[141]440
- 4960 [153]"load (NULL)e've just hinted at the things you
- 4970 print"can do creating and reading disk files.
- 4980 [153]" (NULL)n this sys(NULL)p(NULL)imeprint disk, you'll find
- 4990 print"[198][201][204][197] [210][197][193][196][197][210][153], which uses the techniques
- 5000 [153]"we've looked at here. (NULL)ou can def(NULL)right$(NULL)(NULL)print and
- 5010 print"change it to suit your needs.":print" [201]f you'd like to learn more about
- 5020 [153]"creating and using disk files, look for
- 5030 print" 1541 [213][211][197][210]'[211] [199][213][201][196][197]":print" by [196]r. [199]erald [206]eufeld":print" ([194]rady)
- 5040 [153]"print (NULL)he book should be available through
- 5050 print"any major bookstore.":print" [215]e hope you've had fun seeing how to
- 5060 [153]"make sysdisk filesprint work for you!":[158]q,23,3
- 5070 [153]"list (NULL)ress atn(NULL)(NULL) key to return to (NULL)p(NULL)ime ":[146]198,1:[137]490
-