// -*- ASCII:EDT -*- // TeX: MakeNomencl.edt macro // Created by V. Nikolayev; v1.0 6 december 2006 // This file should go into WinEdt\Exec\MiKTeX\ directory Requires(20040113); // Requires this build of WinEdt to work properly Assign(!"MakeNomencl-Executable", !|makeindex.exe|); Assign(!"MakeNomencl-Switches", !|-s nomencl.ist -o "%N.nls"|); Assign(!"MakeNomencl-Parameters", !|"%N.nlo"|); Release(!"MakeNomencl-Paper_Size"); Release(!"MakeNomencl-Paper_Custom_Size"); Release(!"MakeNomencl-Landscape"); Release(!"MakeNomencl-GUI"); Release(!"MakeNomencl-High_Priority"); Assign(!"MakeNomencl-Wait", !|1|); Release(!"MakeNomencl-Errors"); Release(!"MakeNomencl-Warnings"); Assign(!"MakeNomencl-ExitCode", !|1|); Release(!"MakeNomencl-Viewer"); Release(!"MakeNomencl-View_Search"); Release(!"MakeNomencl-STD_IO"); Release(!"MakeNomencl-No_Interaction"); Release(!"MakeNomencl-C-style-errors"); Release(!"MakeNomencl-Clean_Build"); Release(!"MakeNomencl-Exec_Mode"); Release(!"MakeNomencl-Pause_Active_Only"); Release(!"MakeNomencl-Pause_Error"); Release(!"MakeNomencl-Pause_OK"); SetFocus('MakeNomencl ...'); IfOK('Exit;'); // Already Running: focus it and exit... SaveRegisters(1111111111); // Clean Macro writing... SetOK(1); // Just in case ... SetErrorFlag(0); // Display a Dialog for extra MakeNomencl switches: IfStr("%$('MakeNomencl-GUI');","1","=",> !|GetString("Switches: ","MakeNomencl Switches","%$('MakeNomencl--Switches');");> IfOK(!`Assign('MakeNomencl--Switches','%!?');`,!`Exit;`);|,> !|Release('MakeNomencl--Switches');|); SetOK(1); // Just in case ... SetErrorFlag(0); CloseFile("%b\_Run.log",1); IfStr("%$('MakeNomencl-Wait');","1","=",!|StartWorking("MakeNomencl %N");|); // Delete the working output files... IfFileExists("%b\_Err.log",!"DeleteFile('%b\_Err.log')"); IfFileExists("%b\_Out.log",!"DeleteFile('%b\_Out.log')"); IfFileExists("%b\_Run.log",!"DeleteFile('%b\_Run.log')"); IfFileExists("%P\%N.nls",!"DeleteFile('%P\%N.nls')"); IfFileExists("%P\%N.ilg",!"DeleteFile('%P\%N.ilg')"); SetLogFilename(!"%P\%N.ilg"); UpdateStatus; LetReg(0, !"0"); LetReg(1, !"0"); LetReg(2, !"0"); IfStr("%$('MakeNomencl-Wait');", "1","=",!|LetRegNum(0, "%!0+00100");|); IfStr("%$('MakeNomencl-Exec_Mode');","2","=",!|LetRegNum(0, "%!0+01000");|); IfStr("%$('MakeNomencl-Exec_Mode');","1","=",!|LetRegNum(0, "%!0+10000");|); IfStr("%$('MakeNomencl-STD_IO');", "1","=",!|LetRegNum(0, "%!0+00010");|); IfStr("%$('MakeNomencl-Pause_Active_Only');","1","=",!|LetRegNum(1,"%!1+100");|); IfStr("%$('MakeNomencl-Pause_Error');", "1","=",!|LetRegNum(1,"%!1+010");|); IfStr("%$('MakeNomencl-Pause_OK');", "1","=",!|LetRegNum(1,"%!1+001");|); IfStr("%$('MakeNomencl-High_Priority');","1",!"=",!|LetReg(2,'1');|); LetReg(3, "%$('MakeNomencl-Executable'); %$('MakeNomencl-Switches');"); LetReg(3, "%!3 %$('MakeNomencl--Switches'); %$('MakeNomencl-Parameters');"); Do("LetReg(3, `%!3`);"); // Expand Command Line in Register %!3 // Prompt("%!3"); // For Debugging purposes // *** Execute it!!! SetOK(1); // Just in case WinExe('','%!3','%P','MakeNomencl ...', %!0, %!2,> '', '%b\_Out.log', '%b\_Err.log',%!1); IfOK(!'Relax;',!'StopWorking;> Prompt("Error starting MakeNomencl!%\> See WinEdt''s TeX Configuration Wizard%\> for detailed diagnosis of your TeX system.");> UpdateStatus;RestoreRegisters(1111111111);ErrorLogUpdate;Exit;'); UpdateStatus; IfStr("%$('MakeNomencl-Wait');","1","=",!|Relax;|,!|RestoreRegisters(1111111111);Exit;|); ErrorLogUpdate; IfStr("%$('MakeNomencl-STD_IO');","1","=",> !|> // Create a log file!!!<> OpenOutput('%b\_Run.log'); // Open Run's Log File<> |); // Insert the general information ... GetDate(9, 'dddd, mmmm d, yyyy "at" hh:nn'); // Date Stamp WrL('Output captured by WinEdt on %!9'); WrL(|> ------------------------------------------------------------------%\> %\> WinEdt has successfully executed %$('TeX System'); MakeIndex accessory.%\> %\> If MakeIndex encountered and reported errors the resulting nls file%\> may not appear properly displayed or in some cases may not be%\> created at all. For your convenience WinEdt captured output and%\> error files produced by the MakeIndex accessory.%\> %\> If there are problems (eg. if WinEdt displayed this file) read%\> this output carefully, fix any offending errors in your documents%\> and recompile your sources. If you are having troubles locating%\> and fixing errors please consult the extensive documentation%\> pertaining to MakeNomencl in %$('TeX System'); Doc folder.%\> %\> Hint: WinEdt is almost certainly irrelevant to this situation!%\> %\> ------------------------------------------------------------------%\> |); IfFileExists('%b\_Err.log',!'ReadFile("%b\_Err.log", 9);',!'LetReg(9,"");'); IfStr("%!9","","=",> !"Relax;> WrL('No errors were reported during the execution of makeindex.exe.');> WrL('*** Error File is empty!');> IfFileExists('%b\_Out.log',!'ReadFile(""%b\_Out.log"", 9);',!'LetReg(9,"""");');> IfStr('%!9','','=',> !|WrL;> WrL('*** External application did not produce any console output!');> Relax;|,> !|WrL;> WrL('*** WinEdt captured the following console output:');> WrL;> WrL('%!9');> Relax;|);",> !"Relax;> WrL('Errors were reported during the execution of makeindex.exe.');> WrL('*** WinEdt captured the following error file:');> WrL;> WrL('%!9');> IfFileExists('%b\_Out.log',!'ReadFile(""%b\_Out.log"", 9);',!'LetReg(9,"""");');> IfStr('%!9','','=',> !|WrL;> WrL('*** External application did not produce any console output!');> Relax;|,> !|WrL;> WrL('*** WinEdt captured the following console output:');> WrL;> WrL('%!9');> Relax;|);> Relax;"); IfFileExists('%P\%N.ilg',!'ReadFile("%P\%N.ilg", 9);',!'LetReg(9,"");'); IfStr('%!9','','=',> !|WrL;> WrL('*** MakeIndex did not produce a log file "%N.ilg"!');> Relax;|,> !|WrL;> WrL('*** MakeIndex produced the following log file "%N.ilg":');> WrL;> WrL('%!9');> Relax;|); CloseOutput; // Close Log file IfFileExists("%b\_Err.log",!"DeleteFile('%b\_Err.log')"); IfFileExists("%b\_Out.log",!"DeleteFile('%b\_Out.log')"); RestoreRegisters(1111111111); StopWorking; UpdateStatus; // Update WinEdt's Menu etc... // Exit Code: Errors (non-zero return)? IfStr("%$('MakeNomencl-ExitCode');","1","=",> !|> GetExitCode(0);> IfNum('%!0','0','=',!'Relax;',> !'Prompt("MakeIndex returned nonzero Exit Code (%!0) indicating that some problems might have occurred during the compilation...");');> |); IfFileExists("%P\%N.nls",> !`Relax;`,> // Something is wrong with your TeX system or your document> // Nothing WinEdt can do for you at this stage...> !`Prompt("MakeIndex failed to create a nls file.%\> For possible explanations start the command from the Command Prompt> or read the Log file (captured by WinEdt during the execution)...");> IfFileExists("%b\_Run.log",> !*CloseFile("%b\_Run.log",1);> Open("%b\_Run.log",1,1,-1);GotoCL(1,1);TrackCaret;*);`); RestoreRegisters(1111111111); StopWorking; End;