2
0

exitcode.pas 622 B

12345678910111213141516171819202122232425262728293031323334
  1. {
  2. Compile with Turbo Pascal 7
  3. Runs a DOS program and saves its exit code in file EXITCODE.TXT
  4. }
  5. {$M $4000,0,0} { 16K stack, no heap }
  6. uses
  7. Dos;
  8. var
  9. ProgramName, CmdLine: string;
  10. I: Integer;
  11. ExitCode: LongInt;
  12. Txt: Text;
  13. begin
  14. ProgramName := ParamStr(1);
  15. CmdLine := '';
  16. for I := 2 to ParamCount do
  17. CmdLine := CmdLine + ' ' + ParamStr(I);
  18. SwapVectors;
  19. Exec(ProgramName, CmdLine);
  20. SwapVectors;
  21. if DosError <> 0 then
  22. ExitCode := DosError shl 16 + DosExitCode
  23. else
  24. ExitCode := DosExitCode;
  25. Assign(Txt, 'EXITCODE.TXT');
  26. Rewrite(Txt);
  27. Write(Txt, ExitCode);
  28. Close(Txt);
  29. end.