8-Bit Software Online Conversion

Catalogues - Listing

10DEFFNS="Ofcats" 20MODE7:VDU23;8202;0;0;0; 30DIM FILE$(48) 40A%=0:Y%=0:F%=USR&FFDA MOD&100:REM 1 TAPE 4=DISC 8=ADFS 50A%=0:X%=&FF:M%=USR&FFF4 DIV&100 AND 7:REM 3=MASTER < BBC 60PROCprt("Catalogues. By C.J.Richard son"):LineCount%=2 70IF F%>1VDU21:OSCLI".":VDU6 80IF M%<3 Offset%=&E08 ELSE Offset%=& C008 90IF F%=4PROCread`DFS 100IF F%=8 Offset%=&C405:PROCread`ADFS 110PRINT 120PROCdisplay 130IFF%=1PRINT"Tape? Y/N Change your f /s!" 140IFF%=4PRINT"DFS? Y/N" 150IFF%=8PRINT"ADFS? Y/N" 160REPEATUNTILGET 170PROCdisplay 180IF M%<3 PRINT"Is it a BBC Y/N?" 190IF M%=3 PRINT"Is it a Master Y/N?" 200REPEATUNTILGET:LineCount%=3 210PROCdisplay 220CLS:FORL%=1TO48STEP2:PRINT FILE$(L% );TAB(20);FILE$(L%+1):NEXT 230END 240REM **** 250DEFPROCread`DFS 260FORL%=1TO31 270Locked%=0 280IF?Offset%=0:NEXT:ENDPROC 290I%=?(Offset%+7) 300IFI%>126 I%=I%-128:Locked%=1:REM RE AD DIRECTORY. IS IT LOCKED? 310IFI%=0I%=36 320FILE$(L%)=CHR$(I%)+".":REM TIDY IT UP 330FILE$(L%)=FILE$(L%)+CHR$((?Offset%) -128) 340FORIL%=1TO6 350FILE$(L%)=FILE$(L%)+CHR$(?(Offset%+ IL%)):NEXT 360IF Locked%=1 FILE$(L%)=FILE$(L%)+" L" 370Offset%=Offset%+8 380NEXT 390ENDPROC 400REM **** 410DEFPROCread`ADFS 420FORL%=1TO47 430Read%=0 440Write%=0 450Locked%=0 460Directory%=0 470Endname%=0 480FORO%=0TO9 490I%=?(Offset%+O%) 500IF I%>128 I%=I%-128:PROCattribute`s et 510IF I%=13 Endname%=1 520IF Endname% I%=32 530FILE$(L%)=FILE$(L%)+CHR$(I%) 540NEXT 550FILE$(L%)=FILE$(L%)+" " 560IF Directory% FILE$(L%)=FILE$(L%)+" D" 570IF Locked% FILE$(L%)=FILE$(L%)+"L" 580IF Write% IF NOT Directory% FILE$(L %)=FILE$(L%)+"W" 590IF Read% FILE$(L%)=FILE$(L%)+"R" 600Offset%=Offset%+&1A:IF?Offset%=0 L% =47 610NEXT 620ENDPROC 630DEFPROCattribute`set 640IF O%=0 Read%=1 650IF O%=1 Write%=1 660IF O%=2 Locked%=1 670IF O%=3 Directory%=1 680ENDPROC 690REM ***** 700DEFPROCdisplay 710Count%=0 720Colour%=130 730READA$:A$=CHR$Colour%+A$ 740REPEAT 750B%=INSTR(A$," "):IF B%<>0 B$=LEFT$( A$,B%) ELSE B$=A$ 760Count%=Count%+LEN B$ 770IF INSTR(B$,".n")Count%=99 780IF B$=".ns" LineCount%=99 790IF Count%>38PRINT'CHR$Colour%;:Coun t%=LENB$:LineCount%=LineCount%+1:IFINSTR (B$,".n")Count%=0 800IFLineCount%>20 PRINTTAB(0,21):PROC prt("PRESS SPACE TO CONTINUE"):REPEATUNT ILGET=32:CLS:LineCount%=0:PRINTCHR$Colou r%; 810A$=MID$(A$,LENB$+1):IF INSTR(B$,".n ")=0PRINTB$; 820FORDELAY%=1TO500:NEXT 830IFA$=""READA$ 840UNTILA$="**" 850ENDPROC 860DEFPROCprt(A$):A$=A$+STRING$(LENA$M OD2," "):FORL%=1TOLENA$:PRINTTAB(18-L%/2 );"   ,L%/2):VDU11,11:NEXT:VDU10,10:ENDPROC 870DATA"This program explains how cata logues are held in your computer, and ho w you may use them in a BASIC program." 880DATA" First of all though let me gu ess what filing system you have installe d. Is it: .nl .nl",** 890DATA".nl Actually, to be honest, I know what filing system you are using. T he line that finds out your filing syste m is: .nl .nl" 900DATA"A%=0:Y%=0:A%=USR&FFDA MOD&100 .nl .nl" 910DATA"Then if A% is 1, you are using TAPE .nl" 920DATA"If A%=4, you are using DFS .nl " 930DATA"If A%=8, you are using ADFS .n l .ns" 940DATA"Next, shall guess what compute r you are using .nl",** 950DATA".nl Yes, you guessed it, I kne w what machine you are using too. I know this from this line: .nl .nl" 960DATAA%=0:X%=&FF:A%=USR&FFF4 DIV &10 0 AND 7 970DATA.nl If A%<3 then it is not a Ma ster. .nl .nl 980DATA"It is very relevant to discove r which machine you are using because th e DFS catalogue is held in different pla ces in the BBC and Master. The catalogue s are held in the same format, so it is only a matter of determining " 990DATAthe computer that is in use and adding an offset to the search address. .ns 1000DATAThe address of the DFS catalogu e in the Master is: .nl .nl From &C000 t o &C100. .nl .nl The address for a BBC i s: .nl From &E00 to &F00. .nl .nl 1010DATAThis program knows these addres ses already as it has checked for the ma chine you are using. .nl 1020DATA".nl The first name held is the disc title. After this, file names are held in blocks of 8 bytes. They are stor ed like this: .nl .nl" 1030DATA7 bytes for the name. 1 byte fo r the directory .nl 128 is added to the directory name if it is locked .nl 1040DATA.nl So all we have to do is rea d off the names in blocks of 8 for the m aximum number of filenames possible whic h is of course 31 .ns 1050DATA"The question now is what to do with it once we have read it. Do we jus t print it out? .nl Maybe it would be be tter to store the data in an array. Firs tly then, we must initialize an array of 31 elements " 1060DATAto hold all the information. .n l .nl DIM FILES$(31). .nl .nl Next we ha ve 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 somet hing like this: .nl .nl 1070DATA$.filename L (if locked) .nl . nl This means that we must read the last part of the data first. .nl .nl 1080DATA"then add a . then read the nam e into our array. This is where using an offset really makes things easy. In thi s program, I have used the variable Offs et% to mark the start of each file name in memory, moving " 1090DATA"it on 8 bytes at a time. There fore, at any time we know that if we add 7 to the offset, we will be reading the directory name. .nl .nl " 1100DATARead 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 1110DATA"Just a little bit on storage o f the ADFS catalogue in the Master now. .nl .nl The catalogue for ADFS is held f rom &C400 to &C900. You can get at it in a similar manner as previously describe d. .nl .nl " 1120DATAThe differences from DFS are th is: .nl .nl Names are 10 characters long .nl Names are stored &1A apart .nl 1130DATA"The first 4 bytes of the name hold the file attributes ie if the byte is above 128, the attribute is set, remo ve 128 to get the correct ASCII characte r. .nl .nl" 1140DATA1st letter > 128 = R attribute set .nl 1150DATA2nd letter > 128 = W attribute set .nl 1160DATA3rd letter > 128 = L attribute set .nl 1170DATA4th letter > 128 = D attribute set .nl .nl 1180DATA"As for ADFS in the Model B, I have no idea where the catalogue is stor ed at this juncture. I assume it is in t he &E00 area. Can anyoue tell me? .nl .n l " 1190DATA"Now that the file names are in the array, you can use them for whateve r purpose you want. Strip the attributes for instance and use the string to LOAD or CHAIN programs and so on. .nl .nl " 1200DATAIt just remains to show you you r catalogue now. .ns 1210DATA**