/*
 * Ecomp.ced
 *
 * $VER: Rick Younie Wed Feb 17 18:40:57 1993
 *
 *    please send comments, questions or improvements:
 *         rick@emma.panam.wimsey.bc.ca   1:153/765.9
 *         rick@emma.tfbbs.wimsey.bc.ca
 *
 * USAGE: save this as REXX:Ecomp.ced and
 *    assign a Cygnus Ed function key to Ecomp
 *
 *
 * SYNOPSIS:
 *    has E compile the program in CED, saving any changes first
 *
 * TODO:
 *
 */

/* constants and assigns */

   ec    = 'run:ec -we'         /* change this assignment to your own */

Main:
   signal on ERROR

   address 'rexx_ced'
   options results

      /* open a window for dos i/o */

   call close 'STDOUT'
   call close 'STDIN'
   call open 'STDIN','CON:130/10/510/100'
   call pragma '*','STDIN'
   call open 'STDOUT','*'

      /* find name of file and directory */

   'status 19'
   pathfile = result
   say 'filename is' pathfile

      /* save file if changed */

   'status 18'
  if result ~= 0 then do
      'save' pathfile
      say 'saving changes..'
   end
   else say 'no changes..'

      /* compile it */

   parse var pathfile pf '.e'
   say 'compiling..'
   address 'COMMAND' ec pf
   say '<ret> to close window'
   pull
   'cedtofront'
   exit 0

      /* branches here if RC > 0 from ec */

ERROR:
   errline = RC
   'cedtofront'
   'jump to line' errline
   'okay1' 'error in line #'errline
   exit 0
