%include "inc:util.imp"
%begin {FIRST4: Show first 4 bytes of each .mob file in a directory}
%string(63)directory,filename
  %on 9 %start; %stop; %finish
  directory = cliparam.":"
  openinput(1,directory)
  %cycle
    selectinput(1); readline(filename)
    filename = directory.filename
    tolower(filename)
    %continueunless filename -> (".mob")
    %begin
    %integer n=4,ended=0,k
      %on 3,9 %start
        ended = 1; ->put
      %finish
      openinput(2,filename); selectinput(2)
      %cycle
        readsymbol(k)
put:    %if ended=0 %start
          space; phex2(k)
        %finishelse printstring(" --")
        n = n-1
      %repeatuntil n<=0
      space; space; printline(filename)
      closeinput
    %end
  %repeat
%end
