home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / BSHOW121.ZIP / SPWN13.ZIP / SPAWN.DOC < prev   
Encoding:
Text File  |  1990-01-05  |  15.9 KB  |  310 lines

  1.                             Spawn Version 1.3
  2.                     Public Domain by Albert H. Ariail
  3.                              Copyright 1990
  4.  
  5. The following program is a Desqview specific utility to allow you to 
  6. execute a more or less arbitrary DOS command in the background. This 
  7. program nicely implements what someone has called "the compile in the 
  8. background circus trick".  The background process inherits the default 
  9. directory and the environment that was in effect when spawn was invoked.  
  10. Spawn will execute any DOS internal or external command that does not 
  11. require operator intervention and is otherwise compatible with Desqview.  
  12. Another useful application is to use spawn to force full screen programs 
  13. to load into their own windows.  This makes working in a small DOS 
  14. window much easier. 
  15.  
  16. Hardware/Software requirements:
  17. IBM PC/XT/AT or 100% compatible running DOS 3.x and Desqview 2.x . A 386
  18. processor is not specifically required, but you will certainly get a lot
  19. more out of this program if you have one.
  20.  
  21. ****************************************************************************
  22. *  The above paragraph notwithstanding, at this writing, this program has  *
  23. *  only been tested against DOS 3.3 and Desqview 2.22 .  It is hoped that  *
  24. *  this program will not prove overly version dependent, but if you are    *
  25. *  having trouble with different versions of DOS and/or Desqview, drop me  *
  26. *  a line.  I will fix it if I can. At the very least, I would like to     *
  27. *  update the documentation and supply a graceful exit.                    *
  28. *  I can usually be found on the Interlink Desqview conference at a BBS    *
  29. *  near you, or at Future Technology BBS (617-720-3600).  Less frequently, *
  30. *  I can be reached on Compuserve through an EazyPlex message to           *
  31. *  [73510,2562] .                                                          *
  32. ****************************************************************************
  33.  
  34. If you are new to Desqview, the following definitions may help make this
  35. documentation more intelligible.
  36. I will use the term "parent process" to refer to the Desqview window from 
  37. which you invoke spawn.  It is the function of spawn to open a new 
  38. Desqview window to execute the supplied command.  This will be called the 
  39. "child process".  A process is in the foreground when it can receive input
  40. from the keyboard, otherwise it is in the background.  Foreground windows
  41. are always visible, background windows may or may not be, depending on
  42. whether or not they are behind other windows.  The PIF file for a window
  43. is the Desqview Program Information File that is used to tell Desqview
  44. more about the program that is to be executed.  When you are manipulating
  45. the "Change Program" menu, you are editing the PIF file for that entry.
  46. Under Desqview, a process that is invoked with the keys "XX" will have
  47. a PIF file of c:\dv\xx-pif.dvp .
  48.  
  49. Installation Instructions:
  50. This program assumes that the Desqview executables and all of your PIF 
  51. files reside in the directory C:\DV .  If this is not the case, before 
  52. starting Desqview, you should set the environment variable DESQ to point 
  53. to the correct pathname, e.g. 
  54.  
  55. c> set desq=e:\desqview
  56.  
  57. In what follows if I use the directory c:\dv, I will be referring to 
  58. either this directory or whatever is in the variable DESQ . 
  59.  
  60. After unpacking the archive file, copy file files sp-pif.dvp and 
  61. dvcmd.com to the current Desqview directory.  dvcmd.com file must be 
  62. present in c:\dv and not renamed.  sp-pif.dvp is the Program Information 
  63. File that spawn uses to launch the background process.  This may be 
  64. renamed if you specify the correct (complete) pathname in the environment 
  65. variable SP-PIF . SP does not have to be present in your Desqview "Open 
  66. Process" menu unless you wish to change the default settings.  The program 
  67. spawn.com can reside anywhere accessible from you current PATH variable, 
  68. however, since it doesn't function outside of Desqview, c:\dv would be 
  69. more appropriate. 
  70.  
  71. Basic operation:
  72.  
  73. To invoke a command in a background window, simply enter:
  74.  
  75. c>spawn program [arguments]
  76.  
  77. where program is any valid DOS internal or external command with whatever
  78. arguments it expects, e.g.,
  79.  
  80. c>spawn copy c:\dv\*.* a:
  81.  
  82. If you are executing an external command (a .COM or .EXE file) you can save
  83. about 5K of memory in the child process if you specify a complete pathname
  84. for "program" :
  85.  
  86. c>spawn c:\bin\pkzip.exe -par e:\archive c:\*.*
  87.  
  88. instead of
  89.  
  90. c>spawn pkzip -par e:\archive c:\*.*
  91.  
  92. You can also spawn off pipes and filter programs by enclosing the command
  93. in quotes:
  94.  
  95. spawn "dir *.* | sort >sort.dat"
  96.  
  97. Note that  spawn "dir *.* >dir.dat"
  98. is completely different from   spawn dir *.* >dir.dat
  99. The latter will put the output of spawn in the file dir.dat (usually there
  100. is no output from spawn itself, so dir.dat will be empty).
  101.  
  102. Environment variables used by spawn:
  103.  
  104. CMDSWT -  Defines text which will be placed on the command line whenever 
  105.           spawn invokes command.com. This is usually assigned to a string 
  106.           such as CMDSWT=\e:1500, which for DOS 3.2 or 3.3 will give 
  107.           some additional free space in the child's environment. 
  108.  
  109. SP-MEM -  Defines the amount of memory to be given to the child process 
  110.           e.g., SP-MEM=256 will grant 256k bytes of free memory. If 
  111.           specified, this will override the memory allocation defined in 
  112.           sp-pif.dvp which initially is set to "all you can get". 
  113.  
  114. SP-PIF -  Defines the Desqview Program Information file used by spawn. 
  115.           The default is c:\dv\sp-pif.dvp . You must specify a complete 
  116.           DOS pathname if this is used (for example: c:\desq\spawn.pif or 
  117.           c:\dv\xx-pif.dvp). 
  118.  
  119. DESQ   -  Defines the pathname to the desqview directory. If not 
  120.           specified, c:\dv is assumed.  dvcmd.com must reside in this 
  121.           directory. If the PIF file name has not been changed as 
  122.           described above, sp-pif.dvp must also be in this directory. 
  123.  
  124. COMSPEC - This defines the program name which is used to invoke 
  125.           "command.com" As you probably know, this is generally set by 
  126.           DOS at boot up and is rarely changed by the operator. 
  127.  
  128. Run time options:
  129. Note: all of the options below must be placed immediately after the command
  130. name "spawn" or they will be assumed to be options for the command being
  131. executed, e.g., spawn/f copy ...
  132.  
  133.  /a    - alarm at completion
  134.          This options causes the child process to pause at completion. If 
  135.          running in the background, the child process will be placed in 
  136.          to the foreground.  This allows you to review any exit 
  137.          conditions from the spawned command.  To acknowledge the message, 
  138.          key ESC or click the mouse. 
  139.  
  140.  /s    - silent alarm
  141.          same as /a but less noisy.
  142.  
  143.  /f    - move child to foreground
  144.          Normally the child process is executed in the background. This 
  145.          will force the parent into the background and let the child 
  146.          continue running in the foreground. 
  147.          
  148.  /w    - suspend parent until child completes
  149.          This will stop the parent until the spawned command completes. 
  150.          You may manually restart a waiting process by keying ESC . 
  151.          Normally you will want to use this switch in conjunction with /f.
  152.          This option also gives allows you to retrieve a DOS program 
  153.          return code from the spawned process (see below). 
  154.  
  155.  /d    - disable background operation in parent
  156.          When used with /f, this switch will also suspend the parent 
  157.          until the child completes.  This suspend is softer than /w , the 
  158.          parent process will restart automatically the first time you 
  159.          switch to it. 
  160.  
  161.  /x    - move parent to foreground at exit 
  162.          This will guarantee that the parent returns to the foreground 
  163.          after the child exits. This is normally used in the combination 
  164.          /w/f/x or /d/f/x to insure control returns directly to the 
  165.          parent and not to some other process. 
  166.  
  167.  /p:xx - use alternate pif
  168.          This defines the PIF file to be used in lieu of the default file 
  169.          sp-pif.dvp . This option will also override the environment 
  170.          setting SP-PIF.  This should be used if the program being 
  171.          spawned requires special Desqview options in order to function.  
  172.          This switch /p:ab is short for /p:c:\dv\ab-pif.dvp . You may 
  173.          specify a complete pathname if you wish.  The specified file must 
  174.          be a valid Desqview Program Information File, but does not have 
  175.          to be present on the Desqview "Open Window" menu. 
  176.          
  177.  /m:n  - limit memory to n K
  178.          This provides another way to control the amount of memory the 
  179.          spawned process acquires. /m:256 will give the process 256k of 
  180.          memory. This switch overrides the setting in the specified pif 
  181.          file as well as the environment variable SP-MEM . (see below) 
  182.  
  183. Notes and Ideas:
  184.  
  185. 1.  Watching the spawned process execute.
  186.     You can of course use spawn/f, but this sort of defeats the purpose
  187.     of using spawn.  A more elegant way is to open as small DOS window
  188.     such as D1, move it out of the way and enter something like:
  189.     spawn/p:d1/f/x  copy *.* a:
  190.     The function of the switch combination "/f/x" is to keep the parent
  191.     process in the foreground and not allow the child's window to be
  192.     hidden behind other windows. 
  193.  
  194. 3.  quoted commands.
  195.     spawn implements the "command | command" syntax by starting 
  196.     command.com and then feeding the command text into its keyboard
  197.     followed by and "exit".  This works for pipes and filters, but if
  198.     any of the programs try to read from the keyboard, they will eat
  199.     the "exit" that was intended for command.com .
  200.    
  201. 4.  Using script files with spawn.
  202.     I recommend that you do not attach a script to sp-pif. If you want
  203.     use a script with a spawned process, use /P:XX to specify a PIF
  204.     file that has a script file attached to it.  The script file used
  205.     is not determined by the file name, but rather the field "Keys to
  206.     use on open menu" . If this is say, AB, and a script file
  207.     c:\dv\ab-scrip.dvs exists, Desqview will play it back in the child
  208.     process when spawn starts it.
  209.  
  210. 5.  Getting more environment space in the child process.
  211.     If you spawn off batch files that manipulate the environment with
  212.     the DOS "SET" command, you may get "out of environment space" errors
  213.     from command.com . For DOS 3.2 and 3.3, you can fix this by setting
  214.     the environment variable CMDSWT=\e:nnnn where nnnn is the number of
  215.     bytes you which to allocate to the new environment.  This text will
  216.     be placed on the command line whenever spawn invokes command.com .
  217.     For earlier versions of DOS, you will need to set up some long dummy
  218.     environment variables in the parent window (or better, before you 
  219.     start desqview) such as
  220.     set a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  221.     set b=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
  222.     At the beginning of the batch file that you wish to spawn, clear 
  223.     these variables with
  224.     set a=
  225.     set b=
  226.     This will generally free up enough space for the batch file to 
  227.     continue normally.
  228.  
  229. 6.  Specifying the memory to be given to the child process.
  230.     Initially, the spawn PIF file is configured to allocate as much 
  231.     process memory as is available for the child process.  While this
  232.     is the most general, it is usually far too generous.  For most of the
  233.     programs that you would use will spawn, 256K is more than enough.
  234.     You can always modify sp-pif.dvp to scale back it maximum memory
  235.     allocation, I recommend that you instead set the environment 
  236.     variable SP-MEM=256 .  This will have the same effect, but can be 
  237.     changed more readily.  The SP-MEM setting is overridden by /m:nnn on 
  238.     the command line and is ignored when you specify an alternate pif 
  239.     file with /p:xx .  Spawn will modify the "maximum program memory 
  240.     size" field of the pif file.  If the "memory size" is greater than 
  241.     the "maximum memory" both are set to the specified value.  In all 
  242.     cases, an 10k is added to both fields to help accommodate spawn 
  243.     overhead. 
  244.  
  245. 7.  Modifying SP-PIF.DVP
  246.     Spawn itself is not very sensitive to the set up of the PIF file (as 
  247.     long as there is sufficient memory to start the child process). Spawn 
  248.     will modify the various fields if it needs to.  In particular, the 
  249.     following are always replaced by spawn:
  250.     Program name
  251.     Program parameters
  252.     Directory
  253.     Anything placed in these fields will never be used. As I have 
  254.     mentioned, the process SP does not have to be in the Desqview "Open 
  255.     Window" in order for spawn to function. So after making whatever 
  256.     modifications desired, you may delete the menu item "SP". You must 
  257.     then rename the file sp-pif.bak to sp-pif.dvp in order for spawn to 
  258.     be able to find it. 
  259.      
  260. 8.  Getting the DOS return code from a child.
  261.     When spawn is used with /w, the normal program return code of the 
  262.     child process is returned by spawn to the parent.  This can be used 
  263.     with an "if errorlevel" test inside of a batch file. The return code 
  264.     will correct when following conditions are met: 
  265.     a.  spawn was executed with the /w option
  266.     b.  a complete pathname was given for the executable command
  267.     c.  the command was not enclosed in quotes
  268.     d.  the wait was not aborted with ESC in the parent or a "close window"
  269.         command in the child
  270.     If (d) fails, or some other error occurs, spawn will return a value 
  271.     of 255. Otherwise spawn will return a condition code of 0. 
  272.  
  273. 9.  Using spawn to force a context switch.
  274.     Some text editors have the ability to run a compiler or assembler
  275.     while the user remains inside the editor environment.  Since the
  276.     editor is still in memory, the total ram that is available to the
  277.     compiler is limited.  If the editor can be configured to invoke
  278.     the compiler with something like  spawn /w/f p:bd c:\cc\tcc.exe ...
  279.     then the compiler will run in its own window with a full compliment
  280.     of memory.  The /w switch is appropriate here since the editor must
  281.     wait for the compilation to complete before continuing and may need
  282.     the correct return code from tcc.exe .
  283.     This sort of thing can also be done from a batch file so that full 
  284.     screen editors and the like can be conveniently run from a small 
  285.     Desqview window. For example, if you have an editor say edit.exe, you 
  286.     can create a one line batch file, say ed.bat, containing
  287.     @spawn/d/f/x c:\bin\edit.exe %1 %2 %3 %4 %5 %6 %7 %8 %9 
  288.     The /d will disable the DOS window while the editor is running, but 
  289.     unlike /w, /d will allow the DOS window to restart the first time you 
  290.     select it. The /x will assure that DOS regains control when the editor
  291.     finishes.  Without the /x, if you were to pull up a third window while
  292.     in the editor, control of the keyboard would pass to this window when
  293.     you exit the editor. 
  294.  
  295. 10. If you do not have a 386 processor.
  296.     You can still use spawn for context switching with a non-multitasking
  297.     system.  In this case, the parent process will swap out when spawn is
  298.     invoked.  You will generally want to use /f so that the parent isn't
  299.     swapped back initially.  If the current process is marked non-
  300.     swappable and there isn't sufficient conventional memory to load the
  301.     child process, then spawn will fail with the message "api error
  302.     activating new process".
  303.     You want the child process to run concurrently with the parent, you
  304.     must lower the "maximum program memory" in the parent window to a value
  305.     small enough so that there is sufficient free conventional memory to
  306.     hold both processes.  The exact amount will vary, but a figure of about
  307.     180k will permit one 180k process to spawn.
  308.     
  309.  
  310.