{ Add a message to a news topic }

%external %string (80) Copyright %alias "NEWS_POSTNEWS_ (C)_FDC_RMM_85" = -
   "Copyright (C) 1985 Frank D. Cringle and Richard M. Marshall"

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

%include "IE:Terminal.Inc"
%include "IE:IE.Inc"
!%include "Inc:FS.Imp"
!%include "Inc:FSUtil.Imp"
!%include "Managr:AdDefs.Inc"
!%include "Managr:Admin.Inc"

%constant %string Temp File = "$News_Temp$"

%begin
   %own %string (255) Param = "",
                      Topic = ""
   %integer Done

   {CLOSE DOWN}
   %routine Close Down
      Disconnect Host (News Host)
      Select Host (Home Host)
      %stop
   %end {Close Down}


   %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)
      Cursor (0, 23)
      Clear Line
      Reset Terminal
      Print String ("Screwed up at line: ")
      Write (Event_Line, 0)
      Newline
      Signal (Event_Sub << 4 + Event_Event)      { Not literal indeed ! }
   %finish

   Define Param ("Topic", Topic, PAM Major!PAM No Default)
   Define Param ("Infile - editor by default", Param, PAM Major)

   Process Parameters (CLI Param)

   Home Host = Current Host
   News Host = Connect to Host (News Server)
   Select Host (News Host)
   %if %not Exists (News Directory.Topic) %start
      Print String ("The topic """.Topic.""" does not exist.")
      Newline
      Print String ("Post a request in ""Topics"" if you think ")
      Print String ("it should be created.")
      Newline
      Close Down
   %finish

   Select Host (Home Host)
   %if Param = "" %start
      Open Output (2, Temp File)
      Select Output (2)
      Print String ("Subject: ")
      New Line
      Close Output
      Terminal Model = Default Terminal
      Set Up Terminal
      Done = Edit (Temp File, "", Temp File, 10, 1)
      Reset Terminal
      %if Done = No %start
         Print String ("Aborted")
         New Line
         Close Down
      %finish
      Param = Temp File
   %finish

   Set User
   Close Down %if Post (Param, Topic)
   Close Down
%end
