[comp.sys.apple] Getting Block Counts from BASIC

mdavis@pro-sol.cts.COM (Morgan Davis) (01/01/88)

David Robbins (dr@ski) sez:

> There is a way in BASIC also, from the ProDOS /Examples disk. This is called
> READ.DIRECTORY
> 
>  10  PRINT D$;"OPEN /EXAMPLES,TDIR"
>  20  PRINT D$;"READ /EXAMPLES"
>  30  INPUT L1$: PRINT L1$: REM  READ NAME
>  40  INPUT L2$: PRINT L2$: REM  READ TITLE
>  50  INPUT L3$: PRINT L3$: REM  READ BLANK LINE
>  60  INPUT L4$: PRINT L4$: REM  READ FILES
>  70  IF L4$ <  > "" THEN  GOTO 60
>  80  INPUT L5$: PRINT L5$: REM  READ BLOCK COUNT
>  90  PRINT D$;"CLOSE /EXAMPLES"
> 
> You can then use string handing to take the part of L5$ that has the
> information on total blocks and blocks free.  Note that this reads various
> length directories, and gets to the last status line by waiting for a blank
> line, (the one between the directory info and the status line) in line 70. 
> Obviously, this takes longer since you have to wait for the whole directory
> file to be read in. --  					-dave

Well, if you're into kludging it, yeah, that's an alternative.  It fails with
an END OF DATA ERROR when reading the /RAM volume, by the way.

However, an even cleaner, faster, smoother, better, method from BASIC, is...

10 X = 48820: REM Set/Get info param table
20  DEF  FN DBL(X) = PEEK(X) + PEEK(X + 1) * 256
30  PRINT  CHR$(4) "VERIFY /volumename"
40 BLOCKS = FN DBL(X + 5): USED = FN DBL(X + 8): AVAIL = BLOCKS - USED
50  PRINT "Free: " AVAIL, "Used: " USED, "Total: " BLOCKS

--Morgan Davis

UUCP: [ ihnp4 cbosgd hplabs!hp-sdd sdcsvax nosc ] !crash!pnet01!pro-sol!mdavis
ARPA: crash!pnet01!pro-sol!mdavis@nosc.mil
INET: mdavis@pro-sol.cts.com