%begin
   %recordformat Testfm(%string(15) Id, %integer Start, Finish,
                        %record(Testfm)%name Link)
   %record(Testfm)%array Tests(1:900)
   %owninteger Max Test = 0, Max Id = 0
   %owninteger Conformance=0, Deviance=0, Error=0, Quality=0, impdef=0,
               ImpDep=0, Irregular=0,pretest=0,Extension=0
   %owninteger L1 Conformance=0, L1 Deviance=0, L1 Error=0, L1 Quality=0,
               L1 ImpDef=0,      L1 Pretest=0
   %begin
      %ownbytearray Line(1:80)
      %owninteger Sym = NL, Pos = 0, Lp

      %routine Fill Line
         Lp = 0
         %cycle
            Readsymbol(Sym);  Pos = Pos+1
            %exit %if Sym = NL
            Lp = Lp+1
            Line(Lp) = Sym
         %repeat
      %end

      %on 9 %start
         %return
      %finish

      %routine Get Test(%record(Testfm)%name T)
         %integer j, N, x
         T_Start = Pos
         j = 7;  j = j+1 %until Line(j) = 'T' %or Line(j) = 'P'
         x = j
         T_Id = ""
         %cycle
            T_Id = T_Id.Tostring(Line(j))
            j = j+1
         %repeat %until Line(j) = ','
         %if Lp <= J+7 %start
            Irregular = Irregular+1
         %else %if Line(x) = 'P'
            j=j+1 %until Line(j) = '='
            %if Line(J+1) = 'L' %then L1 Pretest = L1 Pretest+1 -
                                %else Pretest = Pretest+1
         %else
            j=j+1 %until Line(j) = '='
            %if Line(j+1) = 'C' %start
               Conformance = Conformance+1
            %else %if Line(J+1) = 'D'
               Deviance = Deviance+1
            %else %if Line(J+1) = 'Q'
               Quality = Quality+1
            %else %if Line(J+1) = 'E'
               %if Line(J+2) = 'R' %then Error = Error+1 %else -
               %if Line(J+2) = 'X' %then Extension = Extension+1 %else -
                  Irregular = Irregular+1
            %else %if Line(J+1) = 'I' %and Line(J+17) = 'F'
               ImpDef = ImpDef+1
            %else %if Line(J+1) = 'I' %and Line(J+17) = 'P'
               ImpDep = ImpDep+1
            %else %if Line(J+1) = 'L'
               j=j+1 %until Line(j) = '='
               %if Line(j+1) = 'C' %start
                  L1 Conformance = L1 Conformance+1
               %else %if Line(J+1) = 'D'
                  L1 Deviance = L1 Deviance+1
               %else %if Line(J+1) = 'Q'
                  L1 Quality = L1 Quality+1
               %else %if Line(J+1) = 'E'
                  L1 Error = L1 Error+1
               %else %if Line(J+1) = 'I'
                  L1 ImpDef = L1 ImpDef+1
               %else
                  Irregular = Irregular+1
               %finish
            %else
               Irregular = Irregular+1
            %finish
         %finish
         Max Id = Length(T_Id) %if Length(T_Id) > Max Id
         %cycle
            N = Pos
            Fill Line
         %repeat %until Lp = 7 %and Line(1) = '~' -
                               %and Line(2) = 'F' -
                               %and Line(3) = 'I' -
                               %and Line(4) = 'N' -
                               %and Line(5) = 'I' -
                               %and Line(6) = 'S' -
                               %and Line(7) = 'H'
         T_Finish = N-1
      %end

      Printstring("Reading PVSBIN");  Newline
      %begin
         %on 9 %start
            Printstring("Cannot access PVSBIN");  Newline
            %stop
         %finish
         Open Binary Input(1, "PVSBIN");  Select Input(1)
      %end
      %cycle
         Fill Line
         %if Lp > 6 %and Line(1) = '~' -
                    %and Line(2) = 'S' -
                    %and Line(3) = 'T' -
                    %and Line(4) = 'A' -
                    %and Line(5) = 'R' -
                    %and Line(6) = 'T' %start
            Max Test = Max Test+1
            Get Test(Tests(Max Test))
         %finish
      %repeat
   %end

   %routine Show(%string(63) Message, %integer L0, L1)
      Printstring(Message)
      Write(L0, 4)
      Write(L1, 4)
      Write(L0+L1, 4)
      Newline
   %end

   Select Output(0)
   Write(Max Test, 4);  Printstring(" tests found");  Newline
   Show("Conformance             ", Conformance, L1 Conformance)
   Show("Deviance                ", Deviance,    L1 Deviance)
   Show("Implementation Defined  ", ImpDef,      L1 ImpDef)
   Show("Implementation Dependent", ImpDep,      0)
   Show("Errorhandling           ", Error,       L1 Error)
   Show("Pretest                 ", Pretest,     L1 Pretest)
   Show("Quality                 ", Quality,     L1 Quality)
   Show("Extension               ", Extension,   0)
   Show("irregular               ", Irregular,   0)
   %begin
      %integer J, N
      %string(63) S
      Open Output(1, "pvsinc")
      Select Output(1)
      Printstring("%constinteger Max Test =");  Write(Max Test, 1);  Newline
      Printstring("%conststring(");  Write(Max Id, 0)
      Printstring(")%array Test Id(1:Max Test) =")
      N = 0
      %for J = 1, 1, Max Test %cycle
         N = N-1
         N = 5 %and Newline %if N <= 0
         S = Tests(J)_Id
         Spaces(Max Id-Length(S))
         Printstring("""".S."""")
         Printsymbol(',') %unless J = Max Test
      %repeat
      Newline
      Printstring("%constintegerarray Test Start(1:Max Test) =")
      N = 0
      %for J = 1, 1, Max Test %cycle
         N = N-1
         N = 5 %and Newline %if N <= 0
         Write(Tests(J)_Start, 8)
         Printsymbol(',') %unless J = Max Test
      %repeat
      Newline
      Printstring("%constintegerarray Test Finish(1:Max Test) =")
      N = 0
      %for J = 1, 1, Max Test %cycle
         N = N-1
         N = 5 %and Newline %if N <= 0
         Write(Tests(J)_Finish, 8)
         Printsymbol(',') %unless J = Max Test
      %repeat
      Newline
   %end
   Select Output(0)
   Printstring("PVSINC complete");  Newline
%endofprogram
