home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1984 Half 2
/
rerun-1984-07-12.d64
/
datafile
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
228 lines
10 rem datafile 2.6 (c)1983 by mike konshak
12 poke53280,13:poke53281,11:print"[158]":gosub16:ifx=0thengoto66
14 goto68
16 d$=chr$(0):mr$=d$:dr$=d$:s=0:b1$=chr$(10):pw=0:cw=0:b$=chr$(32)
18 nc=0:nl=0:pg=0:f1=0:f2=0:f3=0:l$=d$:rl=0:sb$=d$:cr$=chr$(13):hn$=d$:id$=d$
20 a$=d$:c$=d$:t%=0:i$=d$:ck=0:i=0:j=0:k=0:l=0:m=0:n=0:rw=5:sf=0:z=0:e$="eof"
22 mem=31000:en=0:em$=d$:et=0:es=0:a1$=d$:a2$=d$:a3$=d$:return
24 dim f$(f+1),t%(f+1),l%(f+1):return
26 dim rec$(r+1,f+1),ml$(9,4),pc(10),tt$(5),hc$(9),k%(r+1):return
28 rem--get
30 geta$:ifa$=""then30
32 return
34 rem--create
36 ifck<>0thengosub394
38 print"[147] initialize datafile "
40 clr:gosub16:input"how many fields in each record? 0 [157][157][157][157]";f:iff=0then68
42 gosub24:fori=1tof
44 print"field #";i:print"title ? > "
46 print"length? 0 "
48 print"";tab(6);:inputf$(i):printtab(6);:inputl%(i):nexti
50 rem--compute # records
52 forj=0tof:rl=rl+l%(j):nextj:rl=rl+3*(f+1)+5:r=int((mem-12*(f+1)-2100)/rl)
54 print" your selections will allow approx"
56 printr;"records. a[146]ccept or r[146]eject?"
58 gosub30:ifa$="r"then38
60 ifa$="a"thengosub26:ck=1:goto68
62 goto58
64 rem--menu
66 print"[147] datafile 2.6 (c)1983 by mike konshak ":goto70
68 print"[147] datafile menu "
70 print" c[146]reate new file q[146]uit program
72 [153]" awaitdd record to current file"
74 [153]" mwaitodify record in current file"
76 [153]" dwaitelete record in current file"
78 [153]" rwaitead old file from disk"
80 [153]" pwaitrint records by selection
82 print" v[146]iew file on screen
84 [153]" swaitort records by field
86 print" w[146]rite new file to disk
88 [153]" fwaitormat a disk $wait disk directory
90 print" press the appropriate key "
92 print" there are";x;"records in memory"
94 ifr>0thenprint" space for";r-x;"more records[145]"
96 gosub30:ifa$="a"thengosub350:goto124
98 ifa$="m"thengosub350:goto244
100 ifa$="d"thengosub350:goto272
102 ifa$="c"then36
104 ifa$="r"then170
106 ifa$="p"thengosub354:goto356
108 ifa$="v"thengosub350:goto192
110 ifa$="w"thengosub350:goto144
112 ifa$="s"thengosub350:goto304
114 ifa$="q"then342
116 ifa$="f"then402
118 ifa$="$"then422
120 goto96
122 rem--add records
124 fori=x+1tor:print"[147]press the return[146] key after each entry"
126 print"press return[146] without any entry to stop"
128 print"record number ";i;""
130 forn=1tof
132 printf$(n);" >[157][157][157]";:inputrec$(i,n):ifrec$(i,n)=""thenrec$(i,n)=">"
134 iflen(rec$(i,n))>l%(n)thengosub140:goto132
136 ifrec$(i,1)=">"then x=i-1:ck=1:goto68
138 nextn:k%(i)=i:nexti:x=r:ck=1:goto68
140 print"cannot exceed";l%(n);" characters":return
142 rem--save
144 print"[147]enter name of current file to be saved"
146 print"(12 characters max). any existing file"
148 print"with the same name will be scratched."
150 print" ";nf$:input"[145]";nf$:ifnf$=""then68
152 open15,8,15:print#15,"s0:df] "+left$(nf$,8)+"!old":gosub414
154 print#15,"r0:df] "+left$(nf$,8)+"!old=df] "+nf$:gosub414
156 open5,8,5,"0:df] "+nf$+",s,w":gosub414
158 print#5,r;cr$;f;cr$;x:gosub414:forn=1tof:print#5,f$(n);cr$;l%(n):nextn
160 fori=1tox:print"saving record #";i;"[145][145]"
162 forn=1tof:print#5,rec$(i,n):nextn:gosub414:nexti:print
164 fori=1tox:print"saving pointers";i;"[145][145]":print#5,k%(i):nexti:gosub414
166 print#5,e$:close5:close15:ck=0:goto68
168 rem--load
170 ifck<>0thengosub394
172 clr:gosub16:print"[147]enter name of file to be loaded":inputnf$
174 open15,8,15:open5,8,5,"0:df] "+nf$+",s,r":gosub414
176 input#5,r,f,x:gosub414:gosub24:gosub26:forn=1tof:input#5,f$(n),l%(n):nextn
178 fori=1tox:print"reading record #";i;"[145][145]"
180 forn=1tof:input#5,rec$(i,n):nextn:gosub414:nexti:print
182 fori=1tox:print"reading pointers";i;"[145][145]":input#5,k%(i):nexti
184 gosub414:s=st:ifs<>0then188
186 input#5,e$
188 close5:close15:goto68
190 rem--view
192 i=1
194 ifi=0then68
196 ifi>xthen68
198 print"[147]record number[146]";i;" in file[146] ";nf$;""
200 forn=1tof:print f$(n);": ";rec$(k%(i),n):nextn
202 print" n[146]ext, l[146]ast, j[146]ump, f[146]ind, e[146]xit to menu"
204 gosub30:ifa$="n"theni=i+1:goto194
206 ifa$="l"theni=i-1:goto194
208 ifa$="j"then216
210 ifa$="f"then218
212 ifa$="e"then68
214 goto204
216 input"jump to record number";i:goto194
218 print"[147] find records with common items "
220 forn=1tof:print" ";n;"[146] ";f$(n):nextn
222 input"which field is to be searched? 0 [157][157][157][157]";sf:ifsf=0then68
224 ifsf<1orsf>fthenprint"[145][145][145]":goto222
226 print"enter common item[146] ":print"(the entire string is not required)"
228 print"";f$(sf);"[146] ";:inputt$
230 fori=1tox:print"searching record";i;"[145][145]"
232 ift$=left$(rec$(k%(i),sf),len(t$))then236
234 goto240
236 print"[147] record #";i;"":forn=1tof:printf$(n);": ";rec$(k%(i),n):nextn
238 print" n[146]ext record":gosub30
240 nexti:goto68
242 rem--modify
244 print"[147]modify which record? enter #[146] or a[146]ll":inputmr$:ifmr$=d$then68
246 ifmr$="a"thenmr$=d$:goto254
248 i=val(mr$):mr$=d$
250 ifi>xthengosub348:goto244
252 gosub256:goto68
254 fori=1tox:gosub256:nexti:goto68
256 print"[147]to modify record number";i;", make changes"
258 print"as each field is displayed, then return[146]"
260 forn=1tof:printf$(n)":":print" ";rec$(k%(i),n)
261 if len(rec$(k%(i),n))>36 then print"[145]";
262 print"[145] ";:inputrec$(k%(i),n)
264 iflen(rec$(k%(i),n))>l%(n)thengosub140:goto260
266 ifrec$(k%(i),n)=""thenrec$(k%(i),n)=">"
268 nextn:ck=1:return
270 rem--delete
272 print"[147]delete which record? enter #[146] or a[146]ll"
274 inputdr$:ifdr$=d$then68
276 ifdr$="a"thendr$=d$:goto282
278 i=val(dr$):dr$=d$:ifi>xthengosub348:goto274
280 gosub284:goto68
282 fori=1tox:gosub284:nexti:goto68
284 print"[147]to delete record number";i;", press"
286 print"shift[146] d[146], press space bar[146] to advance"
288 forn=1tof:printf$(n);" ";rec$(k%(i),n):nextn
290 gosub30:ifa$="[196]"then294:rem shifted d
292 ck=1:return
294 print"deleting record";i:print"records may now be out of order"
296 forn=1tof:rec$(k%(i),n)=rec$(x,n):rec$(x,n)="":nextn
298 forj=1tox:ifk%(j)=xthenk%(j)=k%(x):k%(x)=0:x=x-1:goto292
300 nextj
302 rem--sort
304 print"[147] sort records in ascending order "
306 for n=1tof:print" ";n;"[146] ";f$(n):nextn
308 input"which field is to be sorted? 0 [157][157][157][157]";sf:ifsf=0then68
310 ifsf>f thenprint"[145][145][145]":goto308
312 print" please wait[146]":m=x
314 m=int(m/2):ifm=0thenck=1:goto68
316 j=1:k=x-m
318 i=j
320 l=i+m
322 print"sorting [157][157][157][157][157]";i;"[145]"
324 if rec$(k%(i),sf)<=rec$(k%(l),sf) then328
326 t%(n)=k%(i):k%(i)=k%(l):k%(l)=t%(n):i=i-m:ifi>0then320
328 j=j+1:ifj>kthen314
330 goto318
332 rem--quit
334 print"[147] you have not saved your changes!
336 [153]" do you really want to quit? ywait or nwait
338 gosub30:ifa$="y" then344
340 goto68
342 ifck<>0then334
344 print"[147]datafile terminated":end
346 rem--error check
348 print" no such record exists":return
350 ifr>0thenreturn
352 print"[147] no files in memory":fori=1to1000:nexti:goto68
354 ifx<1thengosub352:goto68
356 rem--load print
358 print"[147] printer main menu "
360 print" print records using:
362 [153]" rwaiteports and lists
364 print" m[146]ailing labels
366 [153]" uwaitser defined subprogram
368 print" e[146]xit to main menu
370 [153]" press the appropriate key "
372 [141]30:[139]a$[178]"r"[167]384
374 [139]a$[178]"e"[167]68
376 [139]a$[178]"u"[167]386
378 [139]a$[178]"m"[167]382
380 [137]372
382 [153]"load loading mailing label subprogram":[147]"dfmail",8
384 [153]"load loading report/listing subprogram":[147]"dfreport",8
386 [153]"load enter name of subprogram"
388 [153]"";sb$:[133]"on";sb$:[139]sb$[178]d$[167]358
389 [159]15,8,15:[159]5,8,5,"0:"[170]sb$[170]",p,r":[141]414:[139] en[178]62 [167] 416
390 [147]sb$,8
392 [143]--warning
394 [153]"load this will destroy the file in memory!
396 print" save t