home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vp21beta.zip
/
OEXMPSRC.RAR
/
OS2EXEC
/
TESTEXEC.PAS
< prev
Wrap
Pascal/Delphi Source File
|
2000-08-15
|
3KB
|
73 lines
{█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
{█ █}
{█ Virtual Pascal Examples. Version 2.1 █}
{█ Redirected execution example █}
{█ ─────────────────────────────────────────────────█}
{█ Copyright (C) 1996-2000 vpascal.com █}
{█ █}
{▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}
Program TestExec;
{&PMTYPE VIO}
{$Delphi+,T-,X+,Use32-}
Uses
Crt, Os2Exec, Os2Base, SysUtils;
// This demonstration of capturing the output of a child
// process runs DIR C:\*.* and displays the result in a window.
procedure Directory;
Var
tr : TRedirExec;
i : Integer;
x,y : Integer;
begin
Writeln;
Writeln( 'Executing DIR C:\*.* 5 times, displaying the output in a window' );
tr := TRedirExec.Create; // Create a TRedirExec instance
if Assigned( tr ) then // If creation was ok...
try // Catch any errors
TextColor( White );
For i := 1 to 5 do // Run 5 times
begin
x := 5+5*i; // Set up coordinates of window
y := 3+2*i;
TextBackground( i );
Window( x, y, x+45, y+8 ); // Create Crt window
ClrScr; // Clear it
TextBackground( Black );
Window( x+1, y+1, x+44, y+7 ); // Set up "inside" window
ClrScr; // Clear it in black
{ Execute the command to grab the output from }
tr.Execute( 'CMD.EXE', '/C DIR C:\*.*', nil );
While not tr.Terminated do // While command is executing
If tr.MessageReady then // Ask if a line is ready
Writeln( tr.Message ) // - Display it
else
DosSleep( 30 ); // - otherwise wait a little
end;
Window( 1, 1, 80, 25 ); // Restore screen to normal
TextBackground( Black );
TextColor( LightGray );
Gotoxy( 1, 23 );
finally
tr.Destroy; // Free the instance
end
else
Writeln( 'Error creating TRedirExec class instance' );
end;
begin
ClrScr;
Writeln( 'Redirected Execute Demo v2.1 (C) 1996-2000 vpascal.com' );
PopupErrors := False; // Tell SysUtils to display
// exceptions on user screen
Directory; // Test the function
end.