/* ************************************************************************* */
/*              Future Wave Editor  Sample Macro program.                    */
/*                                                                           */
/*                      Executing compiler macro.                            */
/* ------------------------------------------------------------------------- */
/*   (C) Copyright Future Wave Limited.  1997-1999. All right reserved.      */
/* ************************************************************************* */
trace off

call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs';
call SysLoadFuncs;

szTitle    = "Executing compiler macro";

szCompiler = "icc";                     /* compiler                */
szOption   = "/C";                      /* options for compile.    */


main:
        szPath = FweQueryDir();
        szFile = FweQueryName();

        if length(szFile) > 0 then do
           /* make log file name. */
           szLogName = insert( szPath, "\" );
           szLogName = insert( szLogName, szCompiler );
           szLogName = insert( szLogName, ".Log" );

           /* save current directory and change directory. */
           szCurDir = directory();
           call directory szPath;

           /* executing compiler */
           "call " szCompiler szOption szFile " > " szLogName;

           /* restore current directory */
           call directory szCurDir;

           /* open error-tag-file, if file has errors. */
           if chars(szLogName) > 0 then do
              rc = FweOpen( szLogName );
           end
           else do
              "call del " szLogName;
              RxMessageBox( "Complate !!", szTitle, "OK", "INFORMATION" );
           end;

            /* マクロ実行ログを表示しないのでログを消去 */
            rc = FweClearLog();
        end
        else do
           RxMessageBox( "I have no name.", szTitle, "OK", "ERROR" );
        end;

        exit;
