home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ME22-OS2.ZIP / MACROS.ZIP / COMPMAC.M < prev    next >
Text File  |  1988-01-01  |  2KB  |  54 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /* COMPMAC - quick and dirty little macro to compile a macro in the     */
  4. /*           current buffer.                                            */
  5. /*                                                                      */
  6. /* Thrown together in a hurry by Marc Adler  8/87                       */
  7. /*                                                                      */
  8. /************************************************************************/
  9.  
  10. #define CTRL_F3 224
  11.  
  12. init()
  13. {
  14.   assign_key("compmac", CTRL_F3);       /* Invoked by the CTRL F3 key */
  15. }
  16.  
  17.  
  18. compmac()
  19. {
  20.   /* If the macro file was modified since the last write, then save it */
  21.   if (buffer_modified())
  22.   {
  23.     message("buffer modified --- writing file");
  24.     writefile(filename());
  25.   }
  26.  
  27.   /* Call DOS to invoke maccomp on this macro */
  28.   if (os_command(sprintf("maccomp %s > mac$errs", filename())) < 0)
  29.   {
  30.     message("DOS can't invoke the macro compiler");
  31.     get_tty_char();
  32.     return;
  33.   }
  34.   
  35.   /* See if we had errors in the macro by examining the error output */
  36.   old_buf = currbuf();
  37.   errbuf = setcurrbuf(create_buffer("mac$errs"));
  38.   had_an_error = fsearch("error");
  39.   delete_buffer(errbuf);
  40.   setcurrbuf(old_buf);
  41.   
  42.   if (had_an_error)
  43.   {
  44.     message("The macro had errors in it");
  45.   }
  46.   else
  47.   {
  48.     /* Success!!! Load the macro file into the editor */
  49.     loadmacro(filename());
  50.     message("The macro was compiled successfully and is now loaded");
  51.   }
  52.   get_tty_char();       /* make the user press a key to acknowledge */
  53. }
  54.