home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1985 Summer
/
rerun-1985-summer-side-b.d64
/
renumber
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
77 lines
100 mx=300:dimln(mx):print"[147]basic file renumber":gosub700:z$=chr$(0)
110 close2:close3:close15:print:input"old program name";f1$
120 input"new program name";f2$:ific<>0then190
130 input"starting line number";sn
140 sn=int(sn):ifsn<0then130
150 input"increment";ic
160 ic=int(ic):ific<1then150
170 input"cross reference(y/n)";rf$:ifrf$<>"y"andrf$<>"n"then170
180 ifrf$="y"thendimcr$(mx)
190 print"opening files":open15,8,15
200 printf1$:open2,8,2,"0:"+f1$+",p,r":gosub660:ifer>0then110
210 printf2$:open3,8,3,"0:"+f2$+",p,w":gosub660:ifer>0then110
220 print"pass 1":print
230 get#2,a$:get#2,b$:nl=0:l1=asc(a$+z$)+256*asc(b$+z$)
240 get#2,a$:get#2,b$:l2=asc(a$+z$)+256*asc(b$+z$):ifl2=0then290
250 get#2,a$:get#2,b$:ln(nl)=asc(a$+z$)+256*asc(b$+z$)
260 print"[145]line";ln(nl):nl=nl+1
270 ifnl>=mxthenprint"line table overflow":goto640
280 poke828,l2-l1-4:sys829:l1=l2:goto240
290 close2:open2,8,2,"0:"+f1$+",p,r"
300 print"pass 2":print:gt=137:gs=141:th=167:qu=34:lk=-1
310 ifsn+nl*ic>63999thenprint"line number too big":goto640
320 get#2,a$:get#2,b$:ll=0:l1=asc(a$+z$)+256*asc(b$+z$):n1=l1
330 v=l1:gosub690
340 get#2,a$:get#2,b$:l2=asc(a$+z$)+256*asc(b$+z$):ifl2=0then580
350 get#2,a$:get#2,b$:cl=asc(a$+z$)+256*asc(b$+z$)
360 lk=lk+1:print"[145]line";cl
370 l=l2-l1-4:poke828,l:sys829
380 t2$="":i=851:l=l+i-1:qq=0
390 c=peek(i):ifc=quthenqq=notqq
400 ifgt>corqqthen550
410 ifgt<>candgs<>candth<>cthen550
420 ty$=" ":ifc=gsthenty$=" *"
430 t2$=t2$+chr$(c):t3$="":i=i+1:nf=-1
440 c=peek(i)
450 ifc>47andc<58thennf=0
460 if(c>47andc<58)orc=32thent3$=t3$+chr$(c):i=i+1:goto440
470 ifnfthen410
480 j=0:tn=val(t3$):ln(nl)=tn
490 ifln(j)<>tnthenj=j+1:goto490
500 ifj>=nlthenprint"nonexistent:"tn:print:tn=0:goto520
510 tn=sn+ic*j
520 t3$=str$(tn):t2$=t2$+mid$(t3$,2)
530 ifrf$="y"thencr$(j)=cr$(j)+ty$+mid$(str$(sn+ic*lk),2)
540 ifc=44then430
550 t2$=t2$+chr$(c):i=i+1:ifi<=lthen390
560 n1=n1+len(t2$)+4:v=n1:gosub690:v=sn+ic*ll:gosub690
570 print#3,t2$;:ll=ll+1:l1=l2:goto340
580 print#3,z$+z$;
590 close2:close3:close15:ifrf$<>"y"then640
600 input"crossref(s/p/q)";q$:ifq$="q"then640
610 ifq$="s"thenwi=40:open4,3:gosub750:close4:goto600
620 ifq$="p"thenwi=80:open4,4:gosub750:close4:goto600
630 goto600
640 close2:close3:close15:print:print"done"
650 end
660 input#15,er,e1$,e2,e3:ifer=0thenreturn
670 printer;e1$;e2;e3
680 return
690 print#3,chr$(v-int(v/256)*256);chr$(int(v/256));:return
700 s=0:fori=829to850:readv:pokei,v:s=s+v:nexti
710 ifs=3036thenreturn
720 print"error in data statements":end
730 data162,2,32,198,255,162,0,32,207,255,157
740 data83,3,232,206,60,3,208,244,76,204,255
750 print#4,"cross - reference for "f2$
760 print#4," line references":bl$=" "
770 fori=0tonl:ifcr$(i)=""then850
780 j=2:ifi<>nlthenn$=str$(sn+ic*i)+bl$:print#4,left$(n$,7)"-";:goto800
790 print#4," errors ";
800 k=1
810 ch$=mid$(cr$(i),j,1):print#4,ch$;:j=j+1:k=k+1:ifj>len(cr$(i))then840
820 ifk>wi-14andch$=" "thenprint#4:print#4,bl$;:goto800
830 goto810
840 print#4
850 nexti:return