qp.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
EXEC_PGM.PAS
  Example Contents Index                                    Back
 
PROGRAM exec_pgm;
 
{ EXEC_PGM.PAS illustrates the following procedures:
 
      DosExitCode    Exec    SwapVectors
 
  This program illustrates how a DOS comamnd is executed from within
  the program. If you execute an internal DOS command, use the
  following format:
 
     program name is 'c:\command.com'
     argument string is '/c <dos command>'
}
 
{$M 10000, 0, 0 }
 
USES
    Dos;
 
CONST
    program_name = 'EXEC_PGM ';
    program_desc = 'executes the program you request.';
 
VAR
    command_line : STRING;
    program_path : STRING;
    answer       : Char;
 
BEGIN
 
    Writeln( program_name, program_desc );
    Writeln;
    Writeln( 'To execute an internal DOS command, use the format:' );
    Writeln( '    program name: ''c:\command.com''' );
    Writeln( '    arguments:    ''/c <dos command>''' );
 
    REPEAT
        Write( 'Program to execute: ' );
        Readln( program_path );
        Write( 'Command line arguments for ', program_path, ': ' );
        Readln( command_line );
        Writeln( 'Invoking ', program_path );
 
        SwapVectors;
        Exec( program_path, command_line );
        SwapVectors;
        Writeln( program_path, ' returned DosExitCode ', DosExitCode );
 
        Writeln;
        Write( 'Execute another command (Y/N) ? ' );
        Readln( answer );
    UNTIL UpCase( answer ) <> 'Y';
 
END.