home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1985 June
/
1985-06.d64
/
relative
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
84 lines
0 rem create relative file
1 sys65517:ifpeek(781)=40thenmt$="":goto3
2 mt$=""
3 printmt$"[147] this disk is write":print" protected[146]. please"
4 print" insert a different":print" disk to save the"
5 print" files created with"
6 print" this program.":print" press any key to":print" continue"
9 wait198,1:poke198,0
10 printmt$"[147]length of record":input rl:rl=rl+1
20 print"total number of":input"records";rn:rn=rn+1
30 hb=int(rn/256)
40 lb=rn-hb*256
50 open15,8,15
60 open1,8,2,"rel.file,l,"+chr$(rl)
70 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
80 print#1,"end"
90 close1
95 input#15,e,e$:print"disk status:":printe$:close15
99 rem prepare to write file
100 rc=rc+1
110 rc$=""
120 sp$=" "
130 print"first name":inputnf$
140 print"middle name":inputmn$
150 print"last name":inputln$
160 print"street address":inputsa$
170 print"city":inputci$
180 print"state":inputst$
190 print"zip code":inputzi$
200 print"phone number":inputph$
210 rc$=rc$+left$(nf$+sp$,15)
220 rc$=rc$+left$(mn$+sp$,15)
230 rc$=rc$+left$(ln$+sp$,15)
240 rc$=rc$+left$(sa$+sp$,30)
250 rc$=rc$+left$(ci$+sp$,25)
260 rc$=rc$+left$(st$+sp$,3)
270 rc$=rc$+left$(zi$+sp$,5)
280 rc$=rc$+left$(ph$+sp$,12)
299 rem write to file
300 open15,8,15
310 open1,8,2,"rel.file"
320 hb=int(rc/256)
330 lb=rc-hb*256
340 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
350 print#1,rc$
360 close1
370 input#15,e,e$:print"disk status:":printe$:close15
380 print:print"another entry?"
390 getg$:ifg$=""then390
400 ifg$="n"then500
410 ifg$="y"then100
420 goto390
499 rem read relative file in order
500 fora=1torc:rc$="":print"record #";a
510 open15,8,15
520 open1,8,2,"rel.file"
530 hb=int(a/256)
540 lb=a-hb*256
550 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(1)
560 forb=1to120:get#1,a$:rc$=rc$+a$:next
570 close1:close15
580 printmid$(rc$,1,15)
590 printmid$(rc$,16,15)
600 printmid$(rc$,31,15)
610 printmid$(rc$,46,30)
620 printmid$(rc$,76,25)
630 printmid$(rc$,101,3)
640 printmid$(rc$,104,5)
650 printmid$(rc$,109,12)
660 next
699 rem read individual record
700 print"record # to read":inputre
710 print"starting at position":inputpo
720 hb=int(re/256):lb=re-hb*256
730 open15,8,15
740 open1,8,2,"rel.file"
750 print#15,"p"+chr$(2+96)+chr$(lb)+chr$(hb)+chr$(po)
760 fora=poto120:get#1,a$:printa$;:next
770 input#15,e,e$:print"disk status:":printe$
780 close1:close15
790 print"press any key to continue"
800 getg$:ifg$=""then800
810 goto700