Compucolor.org – Virtual Media

Listing of file='INXDBS.BAS;01' on disk='vmedia/personal_database_dbs_data-sector.ccvf'

100 REM  ** INXDBS - MAY 28,79 **
110 PLOT 6,0,12,14,6,37,3,8,0
120 PRINT " F I L E    R E C O V E R Y    P R O G R A M "
130 PLOT 6,0,15,3,0,6
140 CLEAR 1000:DIM P0(10),D(14),K(14),K$(14),A(14)
150 ADR= 256* PEEK (32941)+ PEEK (32940)
160 DD= PEEK (ADR+ 1):TT= PEEK (ADR+ 2)
170 IF TT= 99THEN SAVE "1:INXDBS":PRINT "ALL PROGRAMS SAVED ":END
180 PLOT 6,0,15,3,10,3
190 IF DD= 2THEN INPUT "INSERT DATA DISK - HIT RETURN ";I$
200 PLOT 6,2,3,0,3,11
210 REM
220 PRINT "   THIS PROGRAM IS USED TO RECOVER AN EXISTING DATA FILE OR"
230 PRINT "   TO INDEX A RANDOM FILE CREATED OUTSIDE DATA BASE."
240 MAX$= "":FOR I= 1TO 19:MAX$= MAX$+ CHR$ (255)
250 PRINT :PRINT TAB( 10)
260 INPUT "ENTER NAME OF RANDOM FILE TO BE INDEXED: ";F$:REM 
270 IF F$= "EXIT"THEN 840
280 F1$= F$:IF DD= 3THEN F$= "1:"+ F$
290 FILE "T",300:FILE "R",2,F$+ ".RND",1:FILE "C",2:PRINT :GOTO 310
300 PRINT TAB( 10);"CANNOT LOCATE ";F1$;"":PRINT :GOTO 250
310 PRINT TAB( 10);"WILL THE FILE BE INDEXED USING THE"
320 PRINT TAB( 10):INPUT "DESCRIPTOR OR INDEX FILE? ";T1$:REM 
330 T$= "DESCRIPTOR":IF LEFT$ (T1$,1)= "I"THEN T$= "INDEX"
340 PRINT TAB( 10);"ENTER THE NAME OF THE ";T$;
350 INPUT " FILE: ";D$:REM 
360 IF  D$= "EXIT"THEN 840
370 D1$= D$:IF DD= 3THEN D$= "1:"+ D$
380 FILE "T",390:GOTO 400
390 PRINT TAB( 10);"CANNOT LOCATE ";D1$;"":PRINT :GOTO 340
400 IF LEFT$ (T1$,1)= "I"THEN FILE "R",3,D$+ ".INF",2:T1= 1:GOTO 430
410 IF LEFT$ (T1$,1)= "D"THEN FILE "R",3,D$+ ".DDL",2:GOTO 430
420 GOTO 310
430 GOSUB 1700
440 PRINT TAB( 10);"THIS WILL TAKE AWHILE....."
450 FILE "A",3,CR,NR,BS,BF
460 FILE "N",F$+ ".INF",NR+ 1- T1,24,5
470 FILE "R",2,F$+ ".INF",3
480 REM


490 FOR I= 1TO NR- T1:GET 3,I+ T1;A$[24]:PUT 2,I+ 1;A$[24]:NEXT I
500 PUT 2,1;0,0,0,MDY,0,0:FILE "C",2,3:FILE "R",3,F$+ ".INF",2
510 REM


520 REM


530 FILE "R",2,F$+ ".RND",1
540 FILE "T",1740:GOTO 550:GOTO 1740
550 SP$= "                                                                "
560 GET 3,2;KY$[16],KL
570 KN= 5
580 RL= (KL+ 8)* KN+ 8
590 RD= INT ((RL+ 127)/ 128)* 128
600 KN= INT ((RD- 8)/ (KL+ 8))
610 IF TT< > 0THEN PRINT TAB( 10);"NUMBER OF KEYS = ";KN:REM 
620 REM


630 FILE "A",2,CR,DL,BS,BF
640 FILE "N",F$+ ".INX",INT (DL/ (INT (KN/ 2)))+ 2,(KL+ 8)* KN+ 8,1
650 FILE "R",1,F$+ ".INX",10
660 REM


670 FOR I= 1TO INT (DL/ (INT (KN/ 2)))+ 1
680 PUT 1,I;0,I+ 1
690 NEXT I
700 FR= 1:FD= DL+ 1:AV= 0
710 GOSUB 930
720 REM


730 FOR B= 1TO DL
740 B$= CHR$ (0)+ CHR$ (0)
750 GET 2,B,3;A$[2]:IF A$= B$THEN 880
760 GET 2,B;X$[KL]:T= ROOT:GOSUB 1220
770 NEXT B
780 REM


790 GET 3,1,13;MDY
800 PUT 3,1;ROOT,FR,FD,MDY,AV,ER
810 FILE "C",1:FILE "C",2:FILE "C",3
820 PRINT TAB( 10);"RECORDS PROCESSES ";DL,"SPACE AVAILABLE ";AV;""
830 PRINT TAB( 10);"ERRORS DETECTED ";ER;"":PRINT
840 IF DD= 2THEN PRINT TAB( 10):INPUT "INSERT PROGRAM DISK - HIT RETURN ;I$
850 IF DD< > 2THEN PRINT TAB( 10):INPUT "HIT RETURN TO CONTINUE ";I$
860 LOAD "MAIN":RUN
870 REM



880 PUT 2,B;CHR$ (FD/ 255)[1],CHR$ (FDAND 255)[1],CHR$ (0)[1],CHR$ (0)[1]
890 FD= B
900 AV= AV+ 1
910 GOTO 770
920 REM



930 V10= KN+ 1
940 V9= KN
950 V4= INT (KN/ 2)
960 V8= 2* V4
970 V5= V4+ 1:V6= V4+ 2:V3= V4- 1
980 RETURN
990 REM
     ** SEARCH(T,X$) **

1000 IF T= 0THEN I= 1:J= 0:RETURN
1010 REM


1020 REM  EXIT P=NODE,I=POSITION,J=0 IF NOT FOUND
1030 P= T:P1= 0:K$(0)= "":P0(P1)= 0
1040 P1= 0
1050 Q= 0
1060 IF P= 0THEN 1190
1070 P1= P1+ 1
1080 P0(P1)= P
1090 GOSUB 1560
1100 K$(0)= ""
1110 K$(N+ 1)= MAX$
1120 I= 0
1130 IF X$> K$(I)THEN I= I+ 1:GOTO 1130
1140 IF LEFT$ (X$+ SP$,KL)= K$(I)THEN J= 1:RETURN
1150 IF K$(I)> X$THEN I= I- 1
1160 Q= P
1170 P= A(I)
1180 IF P< > 0THEN 1060
1190 P= Q:J= 0:IF P< > P0(P1)THEN P1= P1- 1
1200 RETURN
1210 REM



1220 A= 0:K$= X$:D= B:J= 0
1230 A= 0:K$= X$:D= B:J= 0
1240 GOSUB 990
1250 IF J< > 0THEN ER= ER+ 1
1260 IF J= 0THEN 1280
1270 PRINT TAB( 10);"ERROR: DUPLICATE KEY  KEY=";:PLOT 6,7:PRINT X$;"":RETURN
1280 IF P= 0THEN 1490
1290 GOSUB 1560:I= 0
1300 K$(N+ 1)= MAX$:K$(0)= ""
1310 IF K$(I)< K$THEN I= I+ 1:GOTO 1310
1320 N= N+ 1:FOR M= NTO ISTEP - 1
1330 K$(M+ 1)= K$(M):A(M+ 1)= A(M):D(M+ 1)= D(M)
1340 NEXT M
1350 REM


1360 A(I)= A:K$(I)= K$:D(I)= D
1370 M= 0
1380 IF N< V10THEN 1630
1390 FOR J= 1TO V4:PUT 1,P,(KL+ 8)* J- (KL- 1);K$(J)[KL],D(J),A(J):NEXT J
1400 PUT 1,P;V4,A(0)
1410 GET 1,FR;FT,FT
1420 FOR J= V6TO V10:PUT 1,FR,(KL+ 8)* J- (V6* (KL+ 8)- 9);K$(J)[KL],D(J),A(J):NEXT J
1430 PUT 1,FR;V10- V5,A(V5)
1440 D= D(V5)
1450 K$= K$(V5):A= FR:P1= P1- 1:P= P0(P1):FR= FT
1460 I= 0
1470 GOTO 1280
1480 REM



1490 REM  NEW ROOT
1500 T= ROOT
1510 GET 1,FR;FT,FT
1520 PUT 1,FR;1,T,K$[KL],D,A
1530 ROOT= FR:FR= FT
1540 RETURN
1550 REM


1560 REM  GET P
1570 GET 1,P;N,A(0)
1580 FOR M= 1TO N
1590 GET 1,P,(KL+ 8)* M- (KL- 1);K$(M)[KL],D(M),A(M)
1600 NEXT M
1610 RETURN
1620 REM


1630 REM  PUT P
1640 PUT 1,P;N,A(0)
1650 FOR M= 1TO N
1660 PUT 1,P,(KL+ 8)* M- (KL- 1);K$(M)[KL],D(M),A(M)
1670 NEXT M
1680 RETURN
1690 REM


1700 PRINT TAB( 10):INPUT "ENTER TODAYS DATE (M,D,Y): ";M,D,Y:REM 
1710 Y= Y- (INT (Y/ 100)* 100)
1720 MDY= M* 3200+ D* 100+ Y
1730 RETURN
1740 REM


1750 REM  FILE READ ERROR
1760 ER= ER+ BF
1770 FOR B= B+ BFTO DL
1780 GOTO 740