{ Add a message to a news topic }

{ This program is for low-level maintenance only }

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

%include "News_S:News.Inc"

%begin
   %string (255) topic, infile
   %integer c, l

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

   topic = cliparam
   open input(0, infile) %if topic -> topic.(",").infile
   Home Host = Current Host
   News Host = Connect to Host (News Server)
   %if Open News File(topic, 1) %start
      %begin
         %label eof

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

         select output(News Stream)
         set output(File Length)
         select input(0)
         l = 0
         %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)
         Close News File
         Select Host (Home Host)
         select output(0)
         printstring("Message #")
         write(Last Message, 0)
         printstring(" added to topic ".topic)
         newline
      %end
   %else
      Select Host (Home Host)
      select output(0)
      printstring(topic." is in use")
      newline
   %finish
   dis:
   Disconnect Host (News Host)
   Select Host (Home Host)
   open input(0, ":")
%end
