home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / EXECWS.ZIP / EXECWSWP.DOC < prev    next >
Encoding:
Text File  |  1993-01-28  |  5.8 KB  |  131 lines

  1. EXECWSWP - Exec a windowed command with optional minimal-memory mode
  2. --------------------------------------------------------------------
  3. TurboPower Software
  4. 1/93
  5. Version 1.6
  6. Released to the public domain
  7.  
  8. Overview
  9. ------------------------------------------------------------------------------
  10.  
  11. EXECWSWP combines the features of two existing utilities: EXECWIN and EXECSWAP.
  12. Specifically, this is a replacement for EXECWIN. Like EXECWIN, it attempts to
  13. limit a child process's video ouput to a specified region of the screen. This
  14. unit, however, will optionally swap the majority of the parent process to EMS
  15. or disk before calling the child process.
  16.  
  17. The "window" effect is produced by taking over interrupt 21h and controlling
  18. all writes to standard output and error devices. All such writes are rerouted
  19. to the screen, within the specified window. Note that this technique will not
  20. work for programs that write directly to video memory, through the BIOS, or
  21. through some other file handle assigned to the console. It does work with
  22. standard DOS commands, with the TPC.EXE compiler, and with other command line
  23. utilities like ARCX.COM.
  24.  
  25. The swapping technology used here was extracted directly from the existing
  26. EXECSWAP unit and is nearly identical to the ExecWithSwap function in Object
  27. Professional's OpExec. Refer to that documentation for more information on the
  28. swapping process.
  29.  
  30. Using EXECWSWP
  31. ------------------------------------------------------------------------------
  32. EXECWSWP interfaces the following constants and routines:
  33.  
  34. const
  35.   UseEmsIfAvailable : Boolean = True;
  36.  
  37.   This constant determines where swapping will occur. The default is to
  38.   attempt to swap to EMS. Set this to False to force swapping to disk.
  39.  
  40. const
  41.   EmsAllocated : Boolean = False;
  42.   FileAllocated : Boolean = False;
  43.  
  44.   These constants are set to true after the swap space has been allocated (one
  45.   or the other will be True).
  46.  
  47. function ExecWinWithSwap(Path, CmdLine : String;
  48.                          Xlo, Ylo, Xhi, Yhi : Byte;
  49.                          Attr : Byte) : Word;
  50.   {-Windowed DOS EXEC supporting swap to EMS or disk}
  51.  
  52.   This function spawns a child process, forces the output to the specified
  53.   window, and swaps most of the parent program to EMS (or disk) during the
  54.   spawn.
  55.  
  56.   Path is the _complete_ pathname of the program to run. CmdLine should
  57.   contain the command line parameters to be passed to that program. Xlo, Ylo,
  58.   Xh and Yhi define the upper-left and lower-right corners of the window. Attr
  59.   specifies the video attribute for all "windowed" writes.
  60.  
  61.   ExecWinWithSwap will return one of the following status codes:
  62.  
  63.     0  Success
  64.     1  Swap error (no swap storage, disk error, EMS error)
  65.     2  File not found
  66.     3  Path not found
  67.     8  Insufficient memory
  68.  
  69. function InitExecSwap(LastToSave : Pointer; SwapFileName : String) : Boolean;
  70.   {-Initialize for swapping, returning TRUE if successful}
  71.  
  72.   This function prepares for swapping by allocating the swap space (in EMS or
  73.   disk).
  74.  
  75.   LastToSave contains the address of the last byte of the region to be swapped
  76.   to disk (the start to the swapped region is within the EXECWSWP unit
  77.   itself). There are three reasonable values for LastToSave. Passing the
  78.   System variable HeapOrg tells ExecSwap not to save any part of the heap;
  79.   this is the correct option for programs that make no use of the heap.
  80.   Passing HeapPtr causes ExecSwap to save all allocated portions of the heap.
  81.   Only the free list is ignored, so this is a good choice for programs that
  82.   don't fragment the heap. Passing the expression Ptr(Seg(FreePtr^)+$1000, 0)
  83.   tells ExecSwap to save the entire heap, including the free list. This is the
  84.   most conservative option, but it may lead to swap files approaching 640K
  85.   bytes in size.
  86.  
  87.   SwapFileName specifies the name and location of the swap file. If EMS memory
  88.   is available this name won't be used, otherwise InitExecSwap will create a
  89.   new file. InitExecSwap assures that sufficient EMS or disk space exists for
  90.   the swap, otherwise it returns False. It's a good idea, of course, to put
  91.   the swap file on the fastest drive that will hold it, to minimize swap
  92.   times. It's also prudent to avoid a floppy drive, since the user may change
  93.   disks while the child process is active. The swap file remains open, using a
  94.   file handle, until ShutdownExecSwap is called or the program ends.
  95.   InitExecSwap marks the file with the Hidden and System attributes so that
  96.   the user of the child process won't be tempted to delete it.
  97.  
  98. procedure ShutdownExecSwap;
  99.   {-Deallocate swap area}
  100.  
  101.   Deallocates the swap area (either frees EMS memory or closes and deletes the
  102.   swap file).
  103.  
  104. function ExecWindow(Command : string; UseSecond : Boolean;
  105.                     Xlo, Ylo, Xhi, Yhi : Byte;
  106.                     Attr : Byte) : Integer;
  107.   {-Exec a program in a window}
  108.  
  109.   This function performs a simple EXEC and attempts to keep the child
  110.   process's output to the specified portion of the screen. No swapping is
  111.   done.
  112.  
  113.   Command is the complete program name the desired command line
  114.   parameters for that program. UseSecond determines whether a second copy of
  115.   COMMAND.COM will be loaded. Xlo, Ylo, Xhi and Yhi specify the upper-right
  116.   and lower-left corners of the window. Attr specifies the video attribute of
  117.   the windowed output.
  118.  
  119.   Since this eventual results in a call to Object Professional's ExecDos
  120.   routine, refer to that documentation for more information about controlling
  121.   the EXEC process.
  122.  
  123.   This function can return the following status codes (from ExecDos):
  124.  
  125.     0 : Success
  126.     1 : Insufficient memory to store free list
  127.     2 : DOS setblock error before EXEC call
  128.     3 : DOS setblock error after EXEC call  -- critical error!
  129.     4 : Insufficient memory to run DOS command
  130.   else a DOS error code
  131.