10 DEFFNS="Ofcats" 20 MODE7:VDU23;8202;0;0;0; 30 DIM FILE$(48) 40 A%=0:Y%=0:F%=USR&FFDA MOD&100:REM 1 TAPE 4=DISC 8=ADFS 50 A%=0:X%=&FF:M%=USR&FFF4 DIV&100 AND 7:REM 3=MASTER < BBC 60 PROCprt("Catalogues. By C.J.Richardson"):LineCount%=2 70 IF F%>1VDU21:OSCLI".":VDU6 80 IF M%<3 Offset%=&E08 ELSE Offset%=&C008 90 IF F%=4PROCread_DFS 100 IF F%=8 Offset%=&C405:PROCread_ADFS 110 PRINT 120 PROCdisplay 130 IFF%=1PRINT"Tape? Y/N Change your f/s!" 140 IFF%=4PRINT"DFS? Y/N" 150 IFF%=8PRINT"ADFS? Y/N" 160 REPEATUNTILGET 170 PROCdisplay 180 IF M%<3 PRINT"Is it a BBC Y/N?" 190 IF M%=3 PRINT"Is it a Master Y/N?" 200 REPEATUNTILGET:LineCount%=3 210 PROCdisplay 220 CLS:FORL%=1TO48STEP2:PRINT FILE$(L%);TAB(20);FILE$(L%+1):NEXT 230 END 240 REM **** 250 DEFPROCread_DFS 260 FORL%=1TO31 270 Locked%=0 280 IF?Offset%=0:NEXT:ENDPROC 290 I%=?(Offset%+7) 300 IFI%>126 I%=I%-128:Locked%=1:REM READ DIRECTORY. IS IT LOCKED? 310 IFI%=0I%=36 320 FILE$(L%)=CHR$(I%)+".":REM TIDY IT UP 330 FILE$(L%)=FILE$(L%)+CHR$((?Offset%)-128) 340 FORIL%=1TO6 350 FILE$(L%)=FILE$(L%)+CHR$(?(Offset%+IL%)):NEXT 360 IF Locked%=1 FILE$(L%)=FILE$(L%)+" L" 370 Offset%=Offset%+8 380 NEXT 390 ENDPROC 400 REM **** 410 DEFPROCread_ADFS 420 FORL%=1TO47 430 Read%=0 440 Write%=0 450 Locked%=0 460 Directory%=0 470 Endname%=0 480 FORO%=0TO9 490 I%=?(Offset%+O%) 500 IF I%>128 I%=I%-128:PROCattribute_set 510 IF I%=13 Endname%=1 520 IF Endname% I%=32 530 FILE$(L%)=FILE$(L%)+CHR$(I%) 540 NEXT 550 FILE$(L%)=FILE$(L%)+" " 560 IF Directory% FILE$(L%)=FILE$(L%)+"D" 570 IF Locked% FILE$(L%)=FILE$(L%)+"L" 580 IF Write% IF NOT Directory% FILE$(L%)=FILE$(L%)+"W" 590 IF Read% FILE$(L%)=FILE$(L%)+"R" 600 Offset%=Offset%+&1A:IF?Offset%=0 L%=47 610 NEXT 620 ENDPROC 630 DEFPROCattribute_set 640 IF O%=0 Read%=1 650 IF O%=1 Write%=1 660 IF O%=2 Locked%=1 670 IF O%=3 Directory%=1 680 ENDPROC 690 REM ***** 700 DEFPROCdisplay 710 Count%=0 720 Colour%=130 730 READA$:A$=CHR$Colour%+A$ 740 REPEAT 750 B%=INSTR(A$," "):IF B%<>0 B$=LEFT$(A$,B%) ELSE B$=A$ 760 Count%=Count%+LEN B$ 770 IF INSTR(B$,".n")Count%=99 780 IF B$=".ns" LineCount%=99 790 IF Count%>38PRINT'CHR$Colour%;:Count%=LENB$:LineCount%=LineCount%+1:IFINSTR(B$,".n")Count%=0 800 IFLineCount%>20 PRINTTAB(0,21):PROCprt("PRESS SPACE TO CONTINUE"):REPEATUNTILGET=32:CLS:LineCount%=0:PRINTCHR$Colour%; 810 A$=MID$(A$,LENB$+1):IF INSTR(B$,".n")=0PRINTB$; 820 FORDELAY%=1TO500:NEXT 830 IFA$=""READA$ 840 UNTILA$="**" 850 ENDPROC 860 DEFPROCprt(A$):A$=A$+STRING$(LENA$MOD2," "):FORL%=1TOLENA$:PRINTTAB(18-L%/2);"";LEFT$(A$,L%/2);RIGHT$(A$,L%/2);TAB(18-L%/2);"";LEFT$(A$,L%/2);RIGHT$(A$,L%/2):VDU11,11:NEXT:VDU10,10:ENDPROC 870 DATA"This program explains how catalogues are held in your computer, and how you may use them in a BASIC program." 880 DATA" First of all though let me guess what filing system you have installed. Is it: .nl .nl",** 890 DATA".nl Actually, to be honest, I know what filing system you are using. The line that finds out your filing system is: .nl .nl" 900 DATA"A%=0:Y%=0:A%=USR&FFDA MOD&100 .nl .nl" 910 DATA"Then if A% is 1, you are using TAPE .nl" 920 DATA"If A%=4, you are using DFS .nl" 930 DATA"If A%=8, you are using ADFS .nl .ns" 940 DATA"Next, shall guess what computer you are using .nl",** 950 DATA".nl Yes, you guessed it, I knew what machine you are using too. I know this from this line: .nl .nl" 960 DATAA%=0:X%=&FF:A%=USR&FFF4 DIV &100 AND 7 970 DATA.nl If A%<3 then it is not a Master. .nl .nl 980 DATA"It is very relevant to discover which machine you are using because the DFS catalogue is held in different places in the BBC and Master. The catalogues are held in the same format, so it is only a matter of determining " 990 DATAthe computer that is in use and adding an offset to the search address. .ns 1000 DATAThe address of the DFS catalogue in the Master is: .nl .nl From &C000 to &C100. .nl .nl The address for a BBC is: .nl From &E00 to &F00. .nl .nl 1010 DATAThis program knows these addresses already as it has checked for the machine you are using. .nl 1020 DATA".nl The first name held is the disc title. After this, file names are held in blocks of 8 bytes. They are stored like this: .nl .nl" 1030 DATA7 bytes for the name. 1 byte for the directory .nl 128 is added to the directory name if it is locked .nl 1040 DATA.nl So all we have to do is read off the names in blocks of 8 for the maximum number of filenames possible which is of course 31 .ns 1050 DATA"The question now is what to do with it once we have read it. Do we just print it out? .nl Maybe it would be better to store the data in an array. Firstly then, we must initialize an array of 31 elements " 1060 DATAto hold all the information. .nl .nl DIM FILES$(31). .nl .nl Next we have to read the data into the array. Let's read it in in a way that is more like the format we are used to. That is something like this: .nl .nl 1070 DATA$.filename L (if locked) .nl .nl This means that we must read the last part of the data first. .nl .nl 1080 DATA"then add a . then read the name into our array. This is where using an offset really makes things easy. In this program, I have used the variable Offset% to mark the start of each file name in memory, moving " 1090 DATA"it on 8 bytes at a time. Therefore, at any time we know that if we add 7 to the offset, we will be reading the directory name. .nl .nl " 1100 DATARead PROCread_DFS to see how I have done it. This procedure should run on it's own as long as you DIMension an array FILE$(31) first. .nl .nl 1110 DATA"Just a little bit on storage of the ADFS catalogue in the Master now. .nl .nl The catalogue for ADFS is held from &C400 to &C900. You can get at it in a similar manner as previously described. .nl .nl " 1120 DATAThe differences from DFS are this: .nl .nl Names are 10 characters long .nl Names are stored &1A apart .nl 1130 DATA"The first 4 bytes of the name hold the file attributes ie if the byte is above 128, the attribute is set, remove 128 to get the correct ASCII character. .nl .nl" 1140 DATA1st letter > 128 = R attribute set .nl 1150 DATA2nd letter > 128 = W attribute set .nl 1160 DATA3rd letter > 128 = L attribute set .nl 1170 DATA4th letter > 128 = D attribute set .nl .nl 1180 DATA"As for ADFS in the Model B, I have no idea where the catalogue is stored at this juncture. I assume it is in the &E00 area. Can anyoue tell me? .nl .nl " 1190 DATA"Now that the file names are in the array, you can use them for whatever purpose you want. Strip the attributes for instance and use the string to LOAD or CHAIN programs and so on. .nl .nl " 1200 DATAIt just remains to show you your catalogue now. .ns 1210 DATA**