00010 BEGIN 
00020 OPEN (1)"FILELIST"
00030 ERASE "dataout",ERR=00040
00040 SERIAL "dataout"
00050 OPEN (2)"dataout"; LOCK (2)
00060 READ RECORD (1,END=00470)F$; LET COUNT=0
00070 OPEN (3,ERR=00260)F$
00080 LET OUTCNT=0
00090 LET FID$=FID(3),FIN$=FIN(3),KEY$=""
00100 LET T=DEC(FID$(2,1)),RSZ=DEC(FID$(6,2)),KSZ=DEC(FID$(8,2))
00110 IF T=0 THEN LET D$="INDEXED "+QUO+F$+QUO+",0,"+STR(RSZ); LET T$="INDEXED"; GOTO 00270
00120 IF T=2 AND RSZ=0 THEN LET D$="SORT "+QUO+F$+QUO+","+STR(KSZ); LET T$="SORT"; GOTO 00270
00130 IF T<>2 THEN GOTO 00250; REM "Check for MKeyed file
00140 IF LEN(STP(FIN$(86),2,$00$))=0 THEN GOTO 00250
00150 LET Q0=1,Q3=99,Q9=-1,Q$=FIN$(86),Q$=Q$(1,POS($FF$=Q$,-1)); REM "Q$=FIN$(86,POS($FF$=FIN$(86))-1)
00160 WHILE Q0<LEN(Q$)
00170 LET Q2=DEC($00$+Q$(Q0,1)),Q0$="["+STR(DEC($00$+Q$(Q0+1,1)))+":"+STR(DEC($00$+Q$(Q0+2,2))+1)+":"+STR(DEC($00$+Q$(Q0+4,1)))
00180 IF Q2<>Q3 THEN LET Q1=0
00190 IF Q$(Q0+5,1)=$01$ THEN LET Q1$="d" ELSE IF Q$(Q0+5,1)=$02$ THEN LET Q1$="u" ELSE IF Q$(Q0+5,1)=$03$ THEN LET Q1$="du" ELSE LET Q1$=$$
00200 IF Q1$<>$$ THEN LET Q1$=":"+QUO+Q1$+QUO
00210 LET Q0$=Q0$+Q1$+"]",Q0=Q0+8,Q1=Q1+1,Q3=Q2
00220 IF Q9=-1 THEN LET KEY$=Q0$,Q9=Q3 ELSE IF Q9=Q3 THEN LET KEY$=KEY$+"+"+Q0$ ELSE LET KEY$=KEY$+","+Q0$,Q9=Q3
00230 WEND 
00240 LET D$="KEYED "+QUO+F$+QUO+","+KEY$+",0,"+STR(0-RSZ),T$="DIRECT"; GOTO 00270
00250 IF T=2 THEN LET D$="DIRECT "+QUO+F$+QUO+","+STR(KSZ)+",0,"+STR(0-RSZ),T$="DIRECT"; GOTO 00270
00260 PRINT "Invalid type:",F$; CLOSE (3); GOTO 00060
00270 PRINT D$; WRITE RECORD (2)D$
00280 LET OUTCNT=OUTCNT+1; IF OUTCNT>25 THEN GOTO 00410
00290 IF KSZ=0 AND LEN(KEY$)=0 THEN GOTO 00330
00300 LET OUTCNT=OUTCNT+1; IF OUTCNT>25 THEN GOTO 00410
00310 LET K$=KEY(3,END=00410); LET D$="K="+HTA(K$); WRITE RECORD (2)D$
00320 IF T$="SORT" THEN READ (3); GOTO 00280
00330 READ RECORD (3,END=00410)R$; LET COUNT=COUNT+1
00340 IF T$="INDEXED" AND COUNT=1 THEN READ (3,ERR=00350,IND=0) NRECS
00350 IF T$="INDEXED" AND NRECS=0 THEN LET NRECS=2
00360 IF T$="INDEXED" AND NRECS=0 THEN GOTO 00410
00370 LET O=POS($00$<>R$,-1); IF O<>0 THEN LET R$=R$(1,O)
00380 LET D$="D="+HTA(R$); WRITE RECORD (2)D$
00390 IF T$="INDEXED" AND COUNT=NRECS THEN GOTO 00410
00400 GOTO 00280
00410 CLOSE (3)
00420 WRITE RECORD (2)"<eof>"
00430 GOTO 00060
00440 LET O=POS(" "<D$)
00450 LET O=POS($0A$=D$); IF O<>0 THEN LET D$(O,1)=$8A$; GOTO 00450
00460 RETURN 
00470 REM  END OF THE FILE
00480 REM "RELEASE 
00490 END 
