%include "I:UTIL.INC"

%constinteger last partition = 3

%externalroutinespec connect file(%string(255) file, %integer zero,
                                  %integername s, l)

%begin
   %recordformat bitmap fm(%bytearray b(0 : 65535))  { Big enough }
   %record(bitmap fm)%name bm
   %integer s, l, i, which, j, total
   %string(127) command = ""
   %byte x
      %for which = 0, 1, last partition %cycle
         connect file("$:BITMAP." . to string(which + '0'), 0, s, l)
         bm == record(s)
         total = 0
         %for i = 0, 1, l %cycle
            x = bm_b(i)
            %for j = 0, 1, 7 %cycle
               total = total + 1 %if x & 1 # 0
               x = x >> 1
            %repeat
         %repeat
         printstring("Partition ");  write(which, 0)
         printstring(" has ");  write(total, 0)
         printstring(" block");  printsymbol('s') %if total # 1
         printstring(" (")
         print(100 * total / (l << 3), 0, 3)
         printstring("%) used")
         newline
      %repeat
%end %of %program
