75: How can I read
another program's errorlevel value in TP?
A: This question is best
answered by an example. Here is a very
elementary program that returns errorlevel 14 on exiting.
program faq2;
begin
writeln ('Hello world...');
halt(14);
end.
Below is the program that calls FAQ2.EXE and detects its
errorlevel.
{$M 2000,0,0}
uses Dos;
begin
SwapVectors;
Exec ('r:\faq2.exe', ''); (* Execution *)
SwapVectors;
WriteLn('...back from Exec');
if DosError <> 0 then
WriteLn('Dos error #', DosError)
else
WriteLn('Success; child process errorlevel = ', lo
(DosExitCode));
end.
The output should be
Hello world...
...back from Exec
Success; child process errorlevel = 14