{ Add a message 'n' times to a news topic }

{ This program is for low-level maintenance only }

%external %string (80) Copyright %alias "NEWS_GEN_(C)_FDC" = -
   "Copyright (C) 1985 Frank D. Cringle"

%include "News_S:News.Inc"
%include "Inc:Util.Imp"

%begin
   %string (255) topic, infile
   %string(255) subject = "Subject: Test message #"
   %integer c, l, j, n

   %on %event 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 %start
      Newline
      Print String ("Screwed up at line: ")
      Write (Event_Line, 0)
      Newline
      Close News File      { Safe, even if not open }
      Disconnect Host (News Host)
      Select Host (Home Host)
      Signal (Event_Sub << 4 + Event_Event)      { Not literal indeed ! }
   %finish

   topic = cliparam
   prompt("How many times ? ")
   read(n)
   %unless topic -> topic.(",").infile %start
      prompt("Input file ? ")
      readline(infile)
   %finish
   Home Host = Current Host
   News Host = Connect to Host(News Server)
   %if %not Open News File(topic, 1) %start
      Select Host(Home Host)
      select output(0)
      printstring(topic." is in use")
      newline
      %stop
   %finish
   %for j = 1, 1, n %cycle
      %begin
         %label eof

         %on %event 9 %start
            -> eof
         %finish

         Select Host(Home Host)
         open input(0, infile)
         Select Host(News Host)
         select output(News Stream)
         set output(File Length)
         Select Host(Home Host)
         select input(0)
         printstring(subject)
         write(j, 3)
         printstring(" of ")
         write(n, 3)
         newline
         l = length(subject) + 3 + 4 + 3 + 1
         %cycle
            Select Host(Home Host)
            readsymbol(c)
            Select Host(News Host)
            printsymbol(c)
            l = l + 1
         %repeat
         eof:
         Select Host(News Host)
         Log Message(l)
      %end
   %repeat
   Close News File
   Disconnect Host (News Host)
   Select Host (Home Host)
   select output(0)
   printstring("Last Message is ")
   write(Last Message, 0)
   newline
   n = n - 1
   open input(0, ":")
%end
