%begin;      !disc recovery program
   %recordformat parmfm(%short dsno, dact, ssno, sact,
                        %integer p1,p2,p3,p4,p5,p6)
   %record(parmfm) p
   %integer this unit = 0
   %integer from
   %integer max block = 32000
   %recordformat filefm(%integer name1, name2, %short spine, day)
   %recordformat dirfm(%short files, %byte access, check, %short chain,
                       %byte spare, daccess,
                       %record(filefm)%array file(1:42))

   %recordformat blockfm(%short size, addr)

   %recordformat spinefm(%short last, %byte access, check,
                         %integer size,
                         %record(blockfm)%array b(1:126))

   %routine read block(%integer block number, %record(*)%Name block)
      %record(parmfm) p
      p_sact = 1
      p_p1 = block number
      p_p2 = addr(block)
      p_p3 = this unit
      p_p4 = 0
      svc(101, p)
      %if p_p1 # 0 %start
         printstring("Cannot read block")
         write(block number, 1)
         write(p_p1, 6)
         newline
         %signal 13,0
      %finish
   %end
   %routine print file(%record(filefm)%Name f)
      %string(27)%name sn
      %record(parmfm) p
      p_p1 = 0
      p_p2 = 0
      p_p3 = f_name1
      p_p4 = f_name2
      svc(18, p)
      sn == string(addr(p_sact))
      printstring(Sn)
      spaces(15-length(sn))
   %end
   %integer n,j,k,l,z
   %record(dirfm) dir
   %record(filefm)%Name f
   %record(spinefm) spine

   %on 13 %start
      newline
      printstring("End of disc at block")
      write(n, 1)
      newline
      %stop
   %finish
   prompt("Unit: ");  read(this unit)


   prompt("From block: ");  read(n)
   n = n-1
   %cycle
      n = n+1
      read block(n, dir)
!      %continue %unless -100 <= dir_files <= 100
      l = 0;  z = 0
      %for j = 1,1,42 %cycle
         f == dir_file(j)
         %continue %If f_name2 = 0
         ->no %if f_name1 # 0 %and f_name1&X'FFFF' = 0
         read block(f_spine&X'FFFF', spine)
         z = z+1 %if spine_check # '?'
         z = z+1 %if f_name1&X'C0000000' # 0;  !dubious
         l = l+1
         ->no %if z > 8
      %repeat
      %continue %if l = 0
      printstring("Directory found at block")
      write(n, 1)
      newline
      k = 0
      %for j = 1,1,42 %cycle
         f == dir_file(j)
         %continue %If f_name2 = 0
         k = k-1
         %if k <= 0 %start
            k = 4
            newline
            spaces(10)
         %finish
         print file(f)
      %repeat
      newlines(2)
no:%repeat
%endofprogram
