home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1985 Summer / rerun-1985-summer-side-b.d64 / renumber (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  2KB  |  77 lines

  1. 100 mx=300:dimln(mx):print"[147]basic file renumber":gosub700:z$=chr$(0)
  2. 110 close2:close3:close15:print:input"old program name";f1$
  3. 120 input"new program name";f2$:ific<>0then190
  4. 130 input"starting line number";sn
  5. 140 sn=int(sn):ifsn<0then130
  6. 150 input"increment";ic
  7. 160 ic=int(ic):ific<1then150
  8. 170 input"cross reference(y/n)";rf$:ifrf$<>"y"andrf$<>"n"then170
  9. 180 ifrf$="y"thendimcr$(mx)
  10. 190 print"opening files":open15,8,15
  11. 200 printf1$:open2,8,2,"0:"+f1$+",p,r":gosub660:ifer>0then110
  12. 210 printf2$:open3,8,3,"0:"+f2$+",p,w":gosub660:ifer>0then110
  13. 220 print"pass 1":print
  14. 230 get#2,a$:get#2,b$:nl=0:l1=asc(a$+z$)+256*asc(b$+z$)
  15. 240 get#2,a$:get#2,b$:l2=asc(a$+z$)+256*asc(b$+z$):ifl2=0then290
  16. 250 get#2,a$:get#2,b$:ln(nl)=asc(a$+z$)+256*asc(b$+z$)
  17. 260 print"[145]line";ln(nl):nl=nl+1
  18. 270 ifnl>=mxthenprint"line table overflow":goto640
  19. 280 poke828,l2-l1-4:sys829:l1=l2:goto240
  20. 290 close2:open2,8,2,"0:"+f1$+",p,r"
  21. 300 print"pass 2":print:gt=137:gs=141:th=167:qu=34:lk=-1
  22. 310 ifsn+nl*ic>63999thenprint"line number too big":goto640
  23. 320 get#2,a$:get#2,b$:ll=0:l1=asc(a$+z$)+256*asc(b$+z$):n1=l1
  24. 330 v=l1:gosub690
  25. 340 get#2,a$:get#2,b$:l2=asc(a$+z$)+256*asc(b$+z$):ifl2=0then580
  26. 350 get#2,a$:get#2,b$:cl=asc(a$+z$)+256*asc(b$+z$)
  27. 360 lk=lk+1:print"[145]line";cl
  28. 370 l=l2-l1-4:poke828,l:sys829
  29. 380 t2$="":i=851:l=l+i-1:qq=0
  30. 390 c=peek(i):ifc=quthenqq=notqq
  31. 400 ifgt>corqqthen550
  32. 410 ifgt<>candgs<>candth<>cthen550
  33. 420 ty$=" ":ifc=gsthenty$=" *"
  34. 430 t2$=t2$+chr$(c):t3$="":i=i+1:nf=-1
  35. 440 c=peek(i)
  36. 450 ifc>47andc<58thennf=0
  37. 460 if(c>47andc<58)orc=32thent3$=t3$+chr$(c):i=i+1:goto440
  38. 470 ifnfthen410
  39. 480 j=0:tn=val(t3$):ln(nl)=tn
  40. 490 ifln(j)<>tnthenj=j+1:goto490
  41. 500 ifj>=nlthenprint"nonexistent:"tn:print:tn=0:goto520
  42. 510 tn=sn+ic*j
  43. 520 t3$=str$(tn):t2$=t2$+mid$(t3$,2)
  44. 530 ifrf$="y"thencr$(j)=cr$(j)+ty$+mid$(str$(sn+ic*lk),2)
  45. 540 ifc=44then430
  46. 550 t2$=t2$+chr$(c):i=i+1:ifi<=lthen390
  47. 560 n1=n1+len(t2$)+4:v=n1:gosub690:v=sn+ic*ll:gosub690
  48. 570 print#3,t2$;:ll=ll+1:l1=l2:goto340
  49. 580 print#3,z$+z$;
  50. 590 close2:close3:close15:ifrf$<>"y"then640
  51. 600 input"crossref(s/p/q)";q$:ifq$="q"then640
  52. 610 ifq$="s"thenwi=40:open4,3:gosub750:close4:goto600
  53. 620 ifq$="p"thenwi=80:open4,4:gosub750:close4:goto600
  54. 630 goto600
  55. 640 close2:close3:close15:print:print"done"
  56. 650 end
  57. 660 input#15,er,e1$,e2,e3:ifer=0thenreturn
  58. 670 printer;e1$;e2;e3
  59. 680 return
  60. 690 print#3,chr$(v-int(v/256)*256);chr$(int(v/256));:return
  61. 700 s=0:fori=829to850:readv:pokei,v:s=s+v:nexti
  62. 710 ifs=3036thenreturn
  63. 720 print"error in data statements":end
  64. 730 data162,2,32,198,255,162,0,32,207,255,157
  65. 740 data83,3,232,206,60,3,208,244,76,204,255
  66. 750 print#4,"cross - reference for "f2$
  67. 760 print#4," line  references":bl$="        "
  68. 770 fori=0tonl:ifcr$(i)=""then850
  69. 780 j=2:ifi<>nlthenn$=str$(sn+ic*i)+bl$:print#4,left$(n$,7)"-";:goto800
  70. 790 print#4," errors ";
  71. 800 k=1
  72. 810 ch$=mid$(cr$(i),j,1):print#4,ch$;:j=j+1:k=k+1:ifj>len(cr$(i))then840
  73. 820 ifk>wi-14andch$=" "thenprint#4:print#4,bl$;:goto800
  74. 830 goto810
  75. 840 print#4
  76. 850 nexti:return
  77.