{***********************************************************************}
{									}
{ __WinShPgm  Invoke a secondary copy of COMMAND within a window	}
{									}
{ procedure __WinExPgm(X1,Y1,X2,Y2 : byte;				}
{		 ForeAttr,BackAttr : byte;				}
{		     var ErrorCode : word);				}
{									}
{	      X1,Y1,X2,Y2						}
{			The coordinates of the window in which the	}
{			secondary copy of COMMAND executes. (X1,Y1) is	}
{			the upper left corner (column and row), and	}
{			(X2,Y2)is the lower right corner. Unpredictable }
{			results can occur if the values do not define	}
{			a physical window.				}
{	      ForeAttr	The foreground and background attributes of	}
{	      BackAttr	of the window.					}
{	      ErrorCode The returned error status code: 		}
{			0 - File successfully loaded and executed.	}
{			2 - File not found. This error is also returned }
{			    if ProgName is the null string (length 0).	}
{			3 - Path not found.  If a path is specified and }
{			    one of the entries is not present, this	}
{			    code is returned.				}
{			5 - Access denied.  A file not suitable for	}
{			    execution was specified.			}
{			8 - Insufficient memory to load the program.	}
{		       98 - COMSPEC= could not be found in the environ- }
{			    ment.					}
{		       99 - The window coordinates specified do not	}
{			    represent a physical window.		}
{			If DOS version 3.0 or later is used, a call to	}
{			__RetErUtl can be made to return more detail	}
{			on errors 2 through 8.				}
{									}
{ Description This procedure invokes a secondary copy of COMMAND using	}
{	      the procedure __ShellPgm. 				}
{									}
{	      When the COMMAND gains control, all I/O to the		}
{	      standard devices (standard input and output) is forced	}
{	      in the specified window.	Even though any program can	}
{	      executed from this secondary copy, programs that do not	}
{	      use DOS I/O services may not execute properly. Note that	}
{	      Turbo Pascal programs that use the CRT unit, normally	}
{	      write to the display adapter directly, and even if the	}
{	      variable DirectVideo is set to FALSE, call BIOS services	}
{	      directly.  For Turbo Pascal programs that need CRT	}
{	      services to position the cursor, clear the screen, etc.,	}
{	      Input and Output should be reopened as the standard DOS	}
{	      devices.							}
{									}
{	      While COMMAND executes, the cursor position and screen	}
{	      image are altered. It is the responsibility of the	}
{	      calling program to restore the screen.			}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __WinShPgm(	   X1,Y1,X2,Y2 : byte;
		     ForeAttr,BackAttr : byte;
			 var ErrorCode : word);

  var
    Cur10Vector : pointer;

  begin {__WinShPgm}

    { Check that the coordinates specified are reasonable.		}

    if ((X1 > X2) or (Y1 > Y2) or (X1 < 1) or (Y1 < 1)) then
       begin
	 ErrorCode := 99;
	 Exit
       end;

    { Now set the global variables used by the BIOS Video service	}
    { routine.								}

    Lo(WinUpper_) := X1 - 1;
    Hi(WinUpper_) := Y1 - 1;
    Lo(WinLower_) := X2 - 1;
    Hi(WinLower_) := Y2 - 1;
    VideoAttr_	  := (BackAttr shl 4) or ForeAttr;
    GetIntVec($10,Prev10Vector_);
    SetIntVec($10,@__Int10Pgm);

    __ShellPgm(ErrorCode);

    { Finally, reestablish the original interrupt $10 vector.		}

    SetIntVec($10,Prev10Vector_)

  end;	{__WinShPgm}
