
10 FOR I=1 TO 15
20 PRINT
30 NEXT
40 INPUT "DATA BASE NAME";F$
50 IF LEN(F$)>7 THEN F$=LEFT$(F$,7)
60 INPUT "NUMBER OF FIELDS";N
70 DIM A$(N),L(N),C(N),T$(N)
80 FOR I=1 TO N
90 INPUT "FIELD NAME, LENGTH, KEY(Y/N), TYPE(C/N)";A$(I),L(I),X$,T$(I)
100 IF L(I)<1 OR L(I)<>INT(L(I)) THEN 120
110 GOTO 130
120 INPUT "INVALID LENGTH - RE-ENTER";L(I):GOTO 100
130 IF LEFT$(X$,1)="N" THEN C(I)=0:GOTO 160
140 IF LEFT$(X$,1)="Y" THEN C(I)=1:GOTO 160
150 INPUT "INVALID KEY - RE-ENTER";X$:GOTO 130
160 T$(I)=LEFT$(T$(I),1)
170 IF T$(I)="C" THEN 210
180 IF T$(I)="N" THEN 200
190 INPUT "INVALID TYPE - RE-ENTER";T$(I):GOTO 160
200 IF L(I)<>2 AND L(I)<>4 THEN 120
210 NEXT I
220 PRINT
230 INPUT "NUMBER OF RECORDS";Q
240 IF Q<1 OR Q<>INT(Q) THEN 230
250 IF Q>500 THEN PRINT "THAT IS TOO MANY FOR THE DISK":GOTO 230
260 PRINT
270 L=0
280 PRINT
290 PRINT "DATA BASE NAME = ";F$
300 PRINT 
310 PRINT Q;"TOTAL RECORDS IN DATA BASE"
320 PRINT
330 PRINT "FIELD NAME","LENGTH","KEY","TYPE"
340 PRINT
350 FOR I=1 TO N
360 PRINT A$(I),
370 PRINT L(I),
380 L=L+L(I)
390 IF C(I)=1 THEN PRINT "Y", ELSE PRINT "N",
400 PRINT T$(I)
410 NEXT I
420 PRINT
430 INPUT "EVERYTHING OK";Q$
440 IF LEFT$(Q$,1)<>"Y" THEN 850
450 INPUT "IS DATA BASE DISK MOUNTED";Q$
460 IF LEFT$(Q$,1)="Y" THEN 490
470 INPUT "ENTER WHEN NEW DISK IS READY";Q$
480 RESET
490 OPEN "O",1,"X"+F$
500 PRINT #1,Q,N
510 FOR I=1 TO N
520 PRINT #1,L(I);A$(I);",";C(I);T$(I)
530 NEXT I
540 CLOSE 1
550 C=INT(128/L)
560 DIM Z$(N*C)
570 OPEN "R",1,F$
580 A=0
590 A=0
600 FOR J=1 TO C
610 FOR I=1 TO N
620 FIELD #1,A*(I+1-I) AS D$,L(I) AS Z$(I+((J-1)*N))
630 A=A+L(I)
640 NEXT I
650 NEXT J
660 FOR J=1 TO C
670 FOR I=1 TO N
680 IF T$(I)="C" THEN LSET Z$(I+((J-1)*N))=" ":GOTO 710
690 IF L(I)=2 THEN LSET Z$(I+((J-1)*N))=MKI$(0):GOTO 710
700 LSET Z$(I+((J-1)*N))=MKS$(0)
710 NEXT I
720 NEXT J
730 C1=INT(Q/C)
740 IF Q*C<>C1 THEN C1=C1+1
750 FOR I=1 TO C1
760 PUT #1,I
770 NEXT I
780 CLOSE 1
790 PRINT
800 PRINT
810 PRINT "DONE"
