%begin
   %include "inc:chario.imp"
   %include "inc:util.imp"
   %include "inc:fs.imp"
   %include "inc:fsutil.imp"

   %ownstring(255)s="", outfile="",eventmess="",a="",b=""
   %string (80) %array Files (1 : 110)
   %integer Number of Files, old

   %string (255) File, File 1, defext
   %integer I, cc, lc, filelen, sym, hpos=1
   %integer File Number = 0, Wild Lines = 0, Wild Chars = 0

   %routine Do one File (%string (255) File)
      %record (finfof) r
      %integer limit,integer i,j, p
      %string (255) s, dir, f, ext
      %byteinteger b0, b1

      %on %event 3,9 %start ; -> filetoobig; %finish

      %if exists(file) %start
         ext = "" %unless file -> s.(".").ext
         i = 0 %while ext -> s.(".").ext
         to upper(ext)
         filelen = filesize(file)
         %if filelen > 0 %start
            %if ext = "MOB" %start 
               openinput(2, file); selectinput(2)
               readsymbol(b0); readsymbol(b1)
               %if b0 = 16_fe %and old = 0 %and (b1 = 1 %or b1 = 2) %start
                  !New format object module - various flavours
                  printstring(file); spaces(15-length(file))
                  printstring(" Nimped")
                  printstring("  (1)") %if b1 = 1; newline
   
               %elseif b0 = 16_fe %and b1 = 0
                  printstring(file); spaces(15-length(file))
                  printstring(" Old"); newline
   
               %elseif b0 = 16_fe %and b1 = 16_cc
                  printstring(file); spaces(15-length(file))
                  printstring(" Old C"); newline

               %elseif old = 0
                  printstring(file); spaces(15-length(file))
                  printstring(" Neither"); newline
               %finish
               close input
            %finish
         %finish
   
         !Clear input buffer to allow ctrl-<thing> through
         %signal 15 %if 11 <= pendsymbol < ' '
      %finish
      %return
   
file too big:
      printstring(" File too big to analyse"); newline
   %end
   
   
   %routine Do Wild Files (%string (80) Wild File)
      %string (127) Line, Directory, Temp
      %integer Flag = 0, Index


      %on 3,9 %start
         %if Flag = 0 %start
            Event_Message = "Rainer stole event_message again" %if Event_Message = ""
            Print String ("Analyse : ".Event_Message)
            New Line
            %return
         %finish
         -> End Load
      %finish

      Directory = ""
      %if Wild File -> Directory .(":"). Wild File %start; %finish
      Directory = Directory . ":" %if Directory # ""
      Open Input (3, Directory."Directory")
      Select Input (3)
      Flag = 1

      Number of Files = 0
      %cycle
         Read Line (Line)
         %if Matches (Line, Wild File) %start
            Number of Files = Number of Files + 1
            Temp = Directory.Line
            Files (Number of Files) = Temp
         %finish
      %repeat

End Load:
      Close Input
      Select Input (0)

      Index = 1
      %while Index <= Number of Files %cycle
         %if files(index) -> a.("ROMP").b %or files(index) -> a.("HACK").b %start
 printstring(directory."  ".files(index))
         %finish
         Index = Index + 1
      %repeat
   %end

   %on %event 15 %start; -> abend; %finish

   file = ""; old = 0; outfile = ""
   define param("DIR", file, pam major)
   define param("OUT", outfile, 0)
   define boolean params("OLDonly", old, 0)
   process parameters(cli param)
   open output(1, outfile) %and selectoutput(1) %if outfile # ""
   Do Wild files(file.":*.mob")

abend:
   New Line

%endofprogram
