home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / latrobe / e / envsiz.arc / ENVSIZE.DOC < prev   
Text File  |  1986-05-15  |  40KB  |  1,255 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.      
  7.      
  8.      
  9.      
  10.      
  11.      
  12.      
  13.      
  14.      
  15.                                      ENVSIZE
  16.      
  17.                        Environment size control and display
  18.      
  19.      
  20.      
  21.                                 Documentation File
  22.      
  23.      
  24.      
  25.      
  26.      
  27.      
  28.      
  29.                          A shareware product provided by:
  30.      
  31.                           Charles P. Scott / Team Alpha
  32.                               519 Garden Springs Dr.
  33.                              Mt. Sterling, KY  40353
  34.      
  35.      
  36.      
  37.      
  38.      
  39.      
  40.      
  41.                 (C) Copyright Charles P. Scott / Team Alpha, 1986
  42.                                All rights reserved
  43.      
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                         1
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.      
  73.       Limitations on use and distribution
  74.      
  75.         This  product is being distributed as shareware. This means that  it
  76.       can  and should be distributed by any user who possesses a legitimate,
  77.       unmodified copy and follows a few simple rules.
  78.         At  Team  Alpha there are other  products in the works which I  hope
  79.       will relieve some of the frustration of working with a PC. Needless to
  80.       say,  those products are somewhat  more time consuming to create  then
  81.       ENVSIZE and will unfortunatly take some months yet. In the time untill
  82.       they  are available the facilities  which have been created along  the
  83.       way  could be getting some use  by those who can use them. This  gives
  84.       others  a chance to benifit and provides some contact for me with  the
  85.       users who will eventually be evaluating my other products. To this end
  86.       my requests are simply:
  87.      
  88.         A. If  you find this program and the information contained in  the
  89.            documentation  of some value to  you then please send fill  out
  90.            the registration form at the back of this document and send to:
  91.      
  92.                             Charles P. Scott / Team Alpha
  93.                                519 Garden Springs Dr.
  94.                                Mt. Sterling, KY 40353
  95.      
  96.                       Or through Compuserve ( ID: 76556,3335 )
  97.                { Of course any small donations would be appreciated. }
  98.      
  99.         B. You  may  not  charge  any  fee for this software or  for  it's
  100.            distribution. This includes a "DISK FEE" or similar charge.
  101.      
  102.         C. You  may not distribute any  modified copy of this software  or
  103.            it's documentation as the results may somehow end up reflecting
  104.            on my products.
  105.      
  106.         D. You  may not copy or reproduce the documentation for any  other
  107.            propose than as a reference for a single legitimate user.
  108.      
  109.         E. You may not distribute this software or documentation as a part
  110.            of  any  comercial package  or for corporate  or  institutional
  111.            purposes.
  112.      
  113.         I'm  realy not as bad as it  seems from all this. If you have a  use
  114.       for  ENVSIZE which does not conform to the above restrictions,  please
  115.       contact me at the above address or call (606) 498-0181 during business
  116.       hours.
  117.      
  118.         Since  the Shareware concept was first introduced it has been   very
  119.       successful  in distributing a wide variety of first class software and
  120.       rewarding  the  authors  who  participate.  Please take  the  time  to
  121.       distribute  this  software  by  passing  it on in  it's  complete  and
  122.       original form to other "Computerists" and bulletin board systems.
  123.      
  124.      
  125.  
  126.  
  127.                                         2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.         If  you  would please bear with  me, I would like to explain  a  bit
  139.       about  how  this program came  to  be and why I chose this  method  of
  140.       distribution.   It  seems  that  I  have  been  struggling  with   the
  141.       environment  ever  since installing the  hard disk in my  Deskpro  and
  142.       needed to achieve some degree of automation and control over the large
  143.       number  of programs and utilities.  This all came to a crytical  point
  144.       when  I installed my EGA and extended memory card which, so to put it,
  145.       caught MS-DOS with it's pants down. The stop-gap patches I had made to
  146.       COMMAND.COM  which  got  me  this  far down the path  to  ruin  became
  147.       unreliable  at best and a better solution was required. The  technical
  148.       reasons  for all this are described later in this document and  should
  149.       prove  to  be enlightening for  the more casual users. (You hard  core
  150.       computerists  already have bruises on your forehead) So to further the
  151.       cause  I  entered  another  interrupt  level in my  work  and  created
  152.       ENVSIZE.
  153.      
  154.      
  155.       Charles P. Scott / Team Alpha
  156.      
  157.      
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.                                         3
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.      
  205.      
  206.                                    Table of Contents
  207.                                    -----------------
  208.      
  209.      
  210.              1. Overview of Parameters and the Environment
  211.      
  212.                 a) Basic introduction to Parameters and the Environment
  213.      
  214.                 b) Primary and subsequent Command Processors
  215.      
  216.                 c) Location of the Environment(s) in memory
  217.      
  218.              2. Problems with using the environment
  219.      
  220.              3. Solving the problem with ENVSIZE
  221.      
  222.                 a) ENVSIZE command syntax
  223.      
  224.                 b) Environment status display
  225.      
  226.                 c) Adding space to the environment
  227.      
  228.                 d) Batch execution of ENVSIZE
  229.      
  230.              4. Technical Description of ENVSIZE
  231.      
  232.              5. Associated problems and bugs in DOS
  233.      
  234.                 a) Providing Environment space in a SHELL
  235.      
  236.                 b) Avoiding the batch Parameter evaluation bug
  237.      
  238.              6. Registering with Team Alpha
  239.      
  240.      
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.                                         4
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.      1. Overview of Parameters and the Environment
  271.      
  272.        a) Basic introduction to Parameters and the Environment
  273.      
  274.             In  PC-DOS  and MS-DOS a  Parameter is a string of  characters
  275.           which  has a name assigned to it and is stored in an area called
  276.           the  Environment. The information  so stored in the  Environment
  277.           may  be used by a batch process, DOS or may provide  information
  278.           to  certain  programs. These  strings may be created and  listed
  279.           using the command "SET". An example of this is found below.
  280.      
  281.             List all Parameters currently in the Environment.
  282.      
  283.               C>set                     <- Typed by user
  284.               COMSPEC=C:\COMMAND.COM    <- Response from DOS
  285.               PATH=c:\;c:\dos                    
  286.      
  287.             Enter a new Parameter into the Environment.
  288.      
  289.               C>set author=Chuck        <- Enter new Parameter
  290.                     
  291.               C>set                     <- List Parameters in Environment
  292.      
  293.               COMSPEC=C:\COMMAND.COM
  294.               PATH=c:\;c:\dos
  295.               AUTHOR=Chuck              <- Parameter AUTHOR now listed
  296.      
  297.             Delete a Parameter from the Environment.
  298.      
  299.               C>set author=             <- Delete AUTHOR parameter
  300.      
  301.               C>set                     <- Author no longer in Environment
  302.               COMSPEC=C:\COMMAND.COM
  303.               PATH=c:\;c:\dos
  304.      
  305.             The  Primary Command Processor (COMMAND.COM) has access to the
  306.           Environment  and  is allowed  to make permanent changes to  it's
  307.           contents.  In fact some  Parameters are inserted or modified  by
  308.           commands  other than SET Such as PROMPT and PATH. One Parameter,
  309.           COMSPEC,  is  placed in  the environment by the Primary  Command
  310.           Processor  when the system is booted. This parameter is used  by
  311.           the  command  processor to locate  itself on the disk  when  the
  312.           transient portion of COMMAND.COM is overwritten by a program and
  313.           needs  to  be replaced. PROMPT  and PATH are accessed  by  their
  314.           corresponding commands as shown below.
  315.      
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.                                         5
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.               C>prompt=?                <- Set the prompt text
  337.      
  338.               ?set                      <- Notice that prompt is "?"
  339.               COMSPEC=C:\COMMAND.COM
  340.               PATH=c:\;c:\dos           
  341.               PROMPT=?                  <- Prompt text stored here
  342.      
  343.               ?prompt                   <- Restore prompt to default
  344.      
  345.               C>set                     <- PROMPT deleted from Environment
  346.               COMSPEC=C:\COMMAND.COM
  347.               PATH=c:\;c:\dos
  348.      
  349.             Certainly  all of the above  is covered in most of the  MS-DOS
  350.           manuals  and associated books but there is actually more to know
  351.           about the environment and how to use it.
  352.      
  353.        b) Primary and subsequent Command Processors
  354.      
  355.             Before  we can get into the problems with making extensive use
  356.           of  the environment and the need for the ENVSIZE program, it  is
  357.           necessary  to understand where things are in memory and to  some
  358.           extent  how they are organized. First of all we must  understand
  359.           that  at  any  one  time  there may be multiple  copies  of  the
  360.           Environment and the Command Processor.
  361.             When  your PC is first turned on or is rebooted a sequence  of
  362.           events  occurs  which  culminates  with  running a  file  called
  363.           COMMAND.COM. This is the Command Processor. It displays a prompt
  364.           on the display and waits for a command from the user (or a batch
  365.           process).  When  a  command  is entered, the  Command  processor
  366.           evaluates  that  command and  initiates a sequence of events  to
  367.           perform  the requested operation. This Command Processor,  which
  368.           is  loaded  when the  system  is booted, is called  the  Primary
  369.           Command  Processor  and is  located below any other programs  in
  370.           memory  (with  the exception  of installed drivers,  IBMBIO  and
  371.           IBMCOM).
  372.             The command SHELL in BASIC allows a user to seemingly re-enter
  373.           DOS  and  enter commands as if  we had never run basic. In  fact
  374.           what  has  happened  is  that BASIC requested that  the  program
  375.           COMMAND.COM  (found  by  the  Parameter COMSPEC) be run  in  the
  376.           available  memory above BASIC. This results in a secondary  copy
  377.           of the Command Processor which is not exactly like the original.
  378.           Sure  it seems to work  the same but the Environment  Parameters
  379.           which  can then be accessed with  the SET command are a copy  of
  380.           the  originals associated with the Primary Command Processor. As
  381.           a  result of all this any changes made to these Parameters  will
  382.           not  be  seen when  you  finally return to the  Primary  Command
  383.           Processor.  Also there is a difference in where this Environment
  384.           is  located in relation  to the current Command Processor  which
  385.           restricts  adding Parameters (I  will explain how to avoid  this
  386.           problem  later). Since many copies of the Command Processor  and
  387.           it's  Environment may be in memory  at one time, there can be  a
  388.           variety of ways that operation may be different from the Primary
  389.           Command Processor.
  390.  
  391.                                         6
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.             A copy of the Environment and how to find it is also passed to
  403.           each  program as it is  loaded and run. This allows  application
  404.           programs  to  read  Parameters  and  modify them,  although  any
  405.           changes  will only be seen in a subsequent program or SHELL  run
  406.           from that program.
  407.      
  408.        c) Location of the Environment(s) in memory
  409.      
  410.             At  this  point I think  it  would be wise to show  how  these
  411.           things  are located in memory and explain their limitations  and
  412.           the  reasons for them. The following two memory maps show  where
  413.           the  various components are located for just the Primary Command
  414.           Processor and then with another program running.
  415.      
  416.                1) Primary Command Processor Only
  417.                   ************************************* 0k
  418.                   *                                   *
  419.                   *  INT vectors and System Info.     *
  420.                   *                                   *
  421.                   *************************************
  422.                   *                                   *
  423.                   *  IBMBIO, IBMDOS & Device Drivers  *
  424.                   *                                   *
  425.                   *************************************
  426.                   *                                   *
  427.                   *  Primary Command Processor        *
  428.                   *                                   *
  429.                   *************************************
  430.                   *  Primary Environment              *
  431.                   *************************************
  432.                   *                                   *
  433.                      Free memory space
  434.                   *                                   *
  435.                   ************************************* End of RAM
  436.      
  437.                   Note: The Environment Follows the Command Processor.
  438.      
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.                                         7
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.                2) Primary Command Processor and another program
  469.                   ************************************* 0k
  470.                   *                                   *
  471.                   *  INT vectors and System Info.     *
  472.                   *                                   *
  473.                   *************************************
  474.                   *                                   *
  475.                   *  IBMBIO, IBMDOS & Device Drivers  *
  476.                   *                                   *
  477.                   *************************************
  478.                   *                                   *
  479.                   *  Primary Command Processor        *
  480.                   *                                   *
  481.                   *************************************
  482.                   *  Primary Environment              *
  483.                   *************************************
  484.                   *  Program Environment              *
  485.                   *************************************
  486.                   *                                   *
  487.                   *  Program                          *
  488.                   *                                   *
  489.                   *************************************
  490.                   *                                   *    
  491.                      Free memory space
  492.                   *                                   *
  493.                   ************************************* End of RAM
  494.      
  495.                   Note: The program and the Command Processor
  496.                         Environments are boxed in and can't expand.
  497.      
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.                                         8
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.      2. Problems with using the Environment
  535.      
  536.           By  looking  at at the charts  above it can be seen that  when
  537.         only  the Primary Command Processor is loaded, and there are  no
  538.         other  programs  (including  resident programs) in  memory,  the
  539.         highest  occupied area of memory contains the Environment.  This
  540.         means  that  the Environment has  room to be expanded  when  the
  541.         space  required  for the  Parameters being entered (via the  set
  542.         command, PROMPT or PATH) exceeds the size of the environment. As
  543.         far  as  I  know,  all  versions  of  MS/PC-DOS  start  with  an
  544.         environment   size  of  10  paragraphs  (160  bytes).  A   quick
  545.         calculation indicates that this is a fairly small space for even
  546.         modest  use of the environment. Since there is some overhead  in
  547.         the Environment, such as a null (0) between each Parameter and a
  548.         double  null  after the last  one, this really amounts to  about
  549.         five  Parameters  of  thirty  characters each, and that  has  to
  550.         include  the Parameter names and an "=". Needless to say we will
  551.         generally require more space. Fortunately when no other programs
  552.         follow  the Command Processor the Environment is free to  expand
  553.         and will as required.
  554.           The  real problem occurs when another program is loaded  after
  555.         the  Primary Command Processor.  Looking at our second chart  we
  556.         see  that there is no  longer room for expansion of the  Command
  557.         Processor's  Environment. Most PC  users have in their  software
  558.         arsenal   at  least  one  "resident"  program  and  many   users
  559.         automatically  load at least  one with their AUTOEXEC.BAT  file.
  560.         For those people there has been no hope of using any more than a
  561.         very  few  Parameters. Even if  you decide not to load  resident
  562.         programs  at boot-up, there is  a limitation to how much may  be
  563.         entered  into the environment by the AUTOEXEC batch process. The
  564.         reason  is  that  a  small  block  of memory (between  4  and  6
  565.         paragraphs)  is allocated for management of a batch process  and
  566.         it  is placed in the next available memory space, right smack at
  567.         the end of our 10 paragraph Environment. If you don't believe me
  568.         just try using a batch file to place a number of Parameters into
  569.         the Environment and you will see the limitations.
  570.           There  seems  to  be  only one conventional solution  to  this
  571.         problem.  That is to manually enter, at the keyboard, all of the
  572.         Parameters   required   or  enough  Parameters  to   cause   the
  573.         Environment  to  expand  to  the required size. Use  of  "dummy"
  574.         parameters  (ie: set a=xxxxxxxxxxxxxxx) is about the best way of
  575.         doing  it. Then when the size is where you want it you will have
  576.         to remove the dummy Parameters with the SET command to free that
  577.         space  up  and then run  a batch file to continue your  start-up
  578.         sequence.  Fortunately the environment will not then contract on
  579.         you. But what a royal pain!
  580.           When  a  program or another  copy of the Command Processor  is
  581.         loaded  by DOS, a copy  of the current Environment is placed  in
  582.         the  first  available memory and  the program is loaded  in  the
  583.         following  space.  The size  of the Environment "copy"  is  only
  584.         enough  to include those  Parameters in existence at that  time.
  585.         Because  of  this the  new  Environment is boxed in and  has  no
  586.         chance  of  being expanded.  When the loaded program is  another
  587.         copy  of  the Command Processor,  use of the SET command to  add
  588.  
  589.                                         9
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.         Parameters will, for the most part,  be futile.
  601.           Fortunately  there is a hero in our story. In the sections  to
  602.         follow  I will explain how to use the ENVSIZE program to  expand
  603.         the  size of the  Environment for the Primary Command  Processor
  604.         and how to secure space in other copies of the environment.
  605.      
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                                         10
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.      3. Solving the problem with ENVSIZE
  667.      
  668.           The  ENVSIZE  program has been  created to help us  solve  the
  669.         problems associated with what I consider to be reasonable use of
  670.         the  environment. It does  this by expanding the Environment  of
  671.         the Primary Command Processor and reporting on the status of the
  672.         current Environment.
  673.      
  674.        a) ENVSIZE command syntax
  675.      
  676.             There  are  two forms  of command syntax for  the  ENVSIZE
  677.           program.  One  to  report  on  the  status  of  the  current
  678.           Environment  and the other to expand the Primary Environment
  679.           size. If at any time you would like to review these commands
  680.           on line simply type "ENVSIZE" as shown below.
  681.      
  682.             C>envsize
  683.      
  684.             Usage: envsize <paragraphs>      ;add number of paragraphs
  685.                    envsize ?                 ;report size in paragraphs
  686.      
  687.                Note: there will also be a copyright notice and other
  688.                             information displayed.
  689.      
  690.      
  691.      
  692.        b) Environment Status Display
  693.      
  694.             ENVSIZE  can provide information on the current Environment by
  695.           simply entering "ENVSIZE ?".
  696.      
  697.             C>envsize ?
  698.      
  699.             Current environment statistics:
  700.               Size in paragraphs.............(DEC)...... 10
  701.               Size in paragraphs.............(HEX)...... 000A
  702.               Size in bytes..................(DEC)...... 160
  703.               Location of environment........(Segment).. 0F47
  704.               Location of command processor..(Segment).. 0E86
  705.               Current command processor is primary...... YES
  706.      
  707.             The  size  in  paragraphs  is  reported in  both  Decimal  and
  708.           Hexadecimal  for convenience.  The locations of the  Environment
  709.           and   the  Command  Processor  make  it  easy  to  examine   the
  710.           environment  with DEBUG and  help to understand what exactly  is
  711.           happening.  In the above example, for instance, the  Environment
  712.           is  located higher in memory than the Command Processor. This is
  713.           because  the  current  Command  Processor is the  Primary  copy.
  714.           Therefore  the above display would indicate that the Environment
  715.           may  yet be expanded  (provided no resident programs exist).  If
  716.           the "ENVSIZE ?" command said that it was not the Primary Command
  717.           Processor  then  the  Environment  would  be located  below  the
  718.           Command Processor and could not be expanded.
  719.      
  720.  
  721.                                         11
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.        c) Adding space to the Environment
  733.      
  734.             To  add space to  the Environment associated with the  Primary
  735.           Command  Processor  simply enter  "ENVSIZE n", where "n" is  the
  736.           number  of paragraphs you would like to add to the current  size
  737.           (the present maximum is 256).
  738.      
  739.             C>envsize 10
  740.      
  741.             Current environment statistics:
  742.               Size in paragraphs.............(DEC)...... 20
  743.               Size in paragraphs.............(HEX)...... 0014
  744.               Size in bytes..................(DEC)...... 320
  745.               Location of environment........(Segment).. 0F47
  746.               Location of command processor..(Segment).. 0E86
  747.               Current command processor is primary...... YES
  748.      
  749.             The statistics display which follows the command indicates the
  750.           status  after the space has been added. If for any reason it  is
  751.           not  possible  to allocate all  of the desired space, only  that
  752.           available  will be allocated and the status display will reflect
  753.           what was actually obtained.
  754.             There  is  a practical limit  to the size of  the  environment
  755.           above  which  the system will not  be able to use. That size  is
  756.           2048  paragraphs or 32K. I  should hope that would suffice!  Any
  757.           attempt  to  exceed that limit  will result in only  2048  total
  758.           paragraphs for the environment and a message being displayed.
  759.             Additionally  there is a limit imposed by the current  version
  760.           of ENVSIZE which you now have. Unfortunatly the method I used to
  761.           perform  this computerized "slight of hand" requires it to  have
  762.           enough  free space contained in  the program to place it's  code
  763.           above  any action which would  otherwise tend to corrupt it.  To
  764.           provide   a  version  which  would  allow  you  to  expand   the
  765.           Environment to it's full 32k in one shot would therefore require
  766.           a  program about 40K in size. This not only takes up disk  space
  767.           but makes it time consuming to transfer by modem. I promise that
  768.           at some point in the future I will rewrite the code so that this
  769.           will  not  be a problem.  For the time, however, if you  require
  770.           more  than  4k  additional  Environment space you will  have  to
  771.           repeat execution of ENVSIZE.
  772.             If  any attempt is made  to expand any environment other  than
  773.           the  primary copy an informational message will be displayed and
  774.           no action will be taken. For information on how to provide space
  775.           in  other copies of  the Environment, read "Associated  problems
  776.           and bugs".
  777.                
  778.        d) Batch execution of ENVSIZE
  779.      
  780.             Due  to the way ENVSIZE modifies the Environment size  certain
  781.           restrictions  are  placed on it's  use within a batch  file.  To
  782.           better   understand  why  these  restrictions  exist  read   the
  783.           "Technical Description" section which follows. Suffice it to say
  784.           that  I  violated  some  basic  rules of DOS which  would  allow
  785.           corruption  of  the batch process  should you not follow  a  few
  786.  
  787.                                         12
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.           rules.  In essence the safest thing to do in a batch file  after
  799.           the  ENVSIZE command is to chain (transfer execution) to another
  800.           batch file or end the batch process.
  801.             Thefollowing  is  an  example  of  the safest way to  use  the
  802.           ENVSIZE command in a batch file and is how my system boots up.
  803.      
  804.             File name: AUTOEXEC.BAT
  805.      
  806.               envsize 100   
  807.               autoexe2
  808.      
  809.             The AUTOEXE2 command executes a batch file called AUTOEXE2.BAT
  810.           which  continues by  loading certain resident programs,  setting
  811.           the  PATH  and  PROMPT  parameters as well as  those  Parameters
  812.           required  by other programs I  use and starting the DOS shell  I
  813.           use for hard disk management. When the whole process is complete
  814.           I  have  everything set-up the way  I like it, with a 1760  byte
  815.           Environment.  (the original 10 paragraphs + 100 new paragraphs *
  816.           16 bytes/paragraph = 1760)
  817.      
  818.             The rules you should follow when using ENVSIZE in a batch file
  819.           are as follows:
  820.      
  821.                1) Never  follow the ENVSIZE command with a  command
  822.                   which  would add a Parameter to the  Environment,
  823.                   such as the SET, PROMPT or PATH commands.
  824.      
  825.                2) Do  not follow the ENVSIZE command with a command
  826.                   which  would result  in the execution of  another
  827.                   program. You are welcome to try this, but I don't
  828.                   guarantee the results.
  829.      
  830.                3) Only  follow  the  ENVSIZE  command  with  either
  831.                   "INTERNAL"  commands (those which can be executed
  832.                   entirely  by  the  Command  Processor,  ie:  DIR,
  833.                   CHDIR, etc.) or the name of another batch file.
  834.      
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.                                         13
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.      4. Technical Description of ENVSIZE
  865.      
  866.           Simply  put  ENVSIZE  reallocates the memory block  associated
  867.         with  the Primary Environment, using  DOS function 4A, to be  of
  868.         the  desired size. As we know however, any program loaded  after
  869.         the Primary Command Processor will cause allocation of memory at
  870.         the  end  of the  Primary Environment preventing it  from  being
  871.         expanded.  This is therefore true with ENVSIZE. What I have done
  872.         is  to have ENVSIZE deallocate the memory associated with itself
  873.         including  it's Environment before reallocating the  Environment
  874.         space. This may seem to be a bit dangerous because it leaves the
  875.         memory  in which ENVSIZE is executing unallocated. But  actually
  876.         there  is  little which can  cause trouble at that  time  unless
  877.         there  might  happen to be  a real strange resident  program  or
  878.         driver  running.  When  ENVSIZE then terminates,  the  operating
  879.         system  is left only to deallocate the memory which has  already
  880.         been  deallocated, and there seems  to be no trouble with  that.
  881.         Therefore the ENVSIZE scheme works.
  882.           As  usual  there are some  other problems to contend with  and
  883.         they are related to batch processes and Memory Allocation Blocks
  884.         (MAB's). Both are somewhat related. When a batch process is used
  885.         to  call the ENVSIZE program, a small (4 to 6 paragraphs)  block
  886.         of  memory is allocated for batch process housekeeping and it is
  887.         located  in the first available space past the Environment. This
  888.         would   prevent  expansion  of  the  Environment  during   batch
  889.         processes  and  would  severely  limit  the usefulness  of  this
  890.         program.  To circumvent this problem ENVSIZE simply  deallocates
  891.         that block of memory leaving it available for Environment space.
  892.         The  problem with this is that any unwanted modification of this
  893.         area  of memory would result in very unpredictable behavior.  So
  894.         this  won't happen, the ENVSIZE program will not allow less than
  895.         15  paragraphs  to be added,  thus preventing an MAB entry  from
  896.         landing  on top of that memory. This is also why there are  some
  897.         restrictions on the use of ENVSIZE in a batch file. For example,
  898.         if  enough  new Parameters were  then added, the area of  memory
  899.         used  by the batch process would eventually be overwritten since
  900.         it  is  now  part  of  the Environment. When the  batch  process
  901.         eventually terminates, or a new batch file is chained, this area
  902.         will not be used any more except for Parameters. Problem solved.
  903.           The  other part of this problem  is with the PSP and code  for
  904.         ENVSIZE  itself. Since violation of that space could prove to be
  905.         fatal  it is protected by placing the start of the program  code
  906.         4k  up in the code segment. Along with the batch process  space,
  907.         the  PSP is protected by the minimum number of paragraphs  which
  908.         ENVSIZE  will  allow to be  added and the 256 paragraph  maximum
  909.         limit  protects  the  code.  Which  is  why I  have  decided  to
  910.         distribute   this  version  with  a  256  paragraph  limit   per
  911.         execution. The size of ENVSIZE.COM is now about 10 Kbytes rather
  912.         than  the  some 40 K which  would be required to allow the  full
  913.         2048  paragraphs  in  one  shot.  The  compromise  seems  to  be
  914.         reasonable.  I hope at some  later time to have a version  which
  915.         relocates itself and would avoid that limitation.
  916.           I  realy  don't want to wear  out my welcome but there is  one
  917.  
  918.  
  919.                                         14
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.         more  trivial  thing. When a  memory block is allocated  it  has
  931.         placed  in it the segment number of the parent program. So  when
  932.         ENVSIZE  reallocates  the Environment  it, what you  might  say,
  933.         adopts  it.  If  that  memory  block was not  un-adopted  before
  934.         ENVSIZE   terminates  it  would  be  in  danger  of  being  lost
  935.         (deallocated).  To  prevent this  the parent segment  number  is
  936.         returned to that of the Command Processor before termination.
  937.      
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.                                         15
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.      5. Associated problems and bugs in DOS
  997.      
  998.           Just as a point of information and to facilitate better use of
  999.         the  Environment let me explain  a little about the problems  of
  1000.         using Parameters in MS-DOS. As I explained above, there is a way
  1001.         to  provide  space for Parameters  in a copy of the  Environment
  1002.         associated  with a subsequent Command Processor (SHELL). I  will
  1003.         describe  this method and explain how to avoid a bug in the  way
  1004.         the batch processor evaluates parameters.
  1005.      
  1006.        a) Providing Environment space in a SHELL
  1007.      
  1008.             Normally  when a copy of the Environment is provided to  a
  1009.           subsequent  Command  Processor it  is provided with only  as
  1010.           much  space  as is  required by the Parameters it  contains.
  1011.           Since  it  is  not  possible  to  expand that  copy  of  the
  1012.           Environment,  it must have been passed with DUMMY Parameters
  1013.           which  are  there  simply  to  take  up space.  If  in  your
  1014.           AUTOEXEC.BAT  file you use SET to include a number of  these
  1015.           DUMMY Parameters you will always be able to delete them with
  1016.           the  SET command and enter real Parameters. The following is
  1017.           a real example.
  1018.      
  1019.                     Primary Environment before adding DUMMY
  1020.      
  1021.             C>set
  1022.             COMSPEC=C:\COMMAND.COM
  1023.             PATH=c:\;c:\dos
  1024.      
  1025.                     Add the DUMMY Parameter
  1026.      
  1027.             C>set filla=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1028.      
  1029.                     Environment with DUMMY Parameter
  1030.      
  1031.             C>set
  1032.             COMSPEC=C:\COMMAND.COM
  1033.             PATH=c:\;c:\dos
  1034.             FILLA=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  1035.      
  1036.                     Invoke a SHELL
  1037.      
  1038.             C>command
  1039.      
  1040.             The COMPAQ Personal Computer MS-DOS
  1041.             Version 3.10
  1042.      
  1043.             (C) Copyright COMPAQ Computer Corp. 1982,83,84,85
  1044.             (C) Copyright Microsoft Corp. 1981,82,83,84,85
  1045.      
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.                                         16
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.                     Try to insert a Parameter
  1063.      
  1064.             C>set author=Charles P. Scott
  1065.             Out of environment space         <- No space
  1066.      
  1067.                     Remove the DUMMY Parameter
  1068.      
  1069.             C>set fillA=
  1070.      
  1071.             C>set author=Charles P. Scott
  1072.      
  1073.             C>set                            
  1074.             COMSPEC=C:\COMMAND.COM
  1075.             PATH=c:\;c:\dos
  1076.             AUTHOR=Charles P. Scott          <- Took it this time
  1077.      
  1078.             I  suppose you might ask why all this trouble. The  answer
  1079.           lies  with two particular situations. When the SHELL command
  1080.           is  used  from  BASIC  or  a  DOS  SHELL is  invoked  by  an
  1081.           application  program the  user is restricted by  Environment
  1082.           limitations,   especially   with  respect  to   batch   file
  1083.           branching.  Also there is a way to use a subsequent copy  of
  1084.           the Command Processor COMMAND.COM to simulate subroutines in
  1085.           a batch file. But that is another subject which is addressed
  1086.           in several of the better MD-DOS books.
  1087.      
  1088.      
  1089.      
  1090.        b) Avoiding the batch Parameter evaluation bug
  1091.      
  1092.             Just in case you have not already run across the Parameter
  1093.           evaluation bug in MS-DOS I will describe it here and explain
  1094.           how  to avoid it. The problem occurs when an IF statement is
  1095.           used to evaluate a parameter as shown here.
  1096.      
  1097.             IF %AUTHOR%==Charles P. Scott goto SKIP
  1098.             .
  1099.             .
  1100.             :SKIP
  1101.             .
  1102.      
  1103.             When  the Parameter "AUTHOR" exists in the Environment the
  1104.           string  "%AUTHOR%"  is  substituted  with  that  Parameter's
  1105.           value.  If It does not  exist it is evaluated as  "AUTHOR%",
  1106.           without  the leading "%". Actually this is a benefit because
  1107.           it allows you to test for a non-existent Parameter as in the
  1108.           statement below.
  1109.      
  1110.             IF %AUTHOR%==AUTHOR% goto NOTFOUND
  1111.      
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.                                         17
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.             Well at least that is true up to my Compaq DOS version 3.1
  1129.           where  they have apparently tried to save face and ruined it
  1130.           for us. Now the nonexistent Parameter is evaluated to a null
  1131.           string  (no  characters) and  will always produce  a  syntax
  1132.           error.
  1133.      
  1134.             IF ==Charles P. Scott goto SKIP
  1135.      
  1136.             That  is how the line would try to execute in that version
  1137.           of DOS and would cause an error. With such a "correction" it
  1138.           becomes  impossible  to  branch on a  nonexistent  Parameter
  1139.           without first eliminating all other possibilities!
  1140.      
  1141.           I  hope that you have found this information of some value and
  1142.         not  too much of a bore. Please don't hesitate to contact me  if
  1143.         you  have  any comments  on  the above material or  the  program
  1144.         itself.  Certainly if you find there to be some problems, let me
  1145.         know so that I can help you work them out or correct for them in
  1146.         future versions.
  1147.      
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.                                         18
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.      
  1195.      6. Registration with Team Alpha
  1196.      
  1197.         Once you have evaluated this program fill out the following form
  1198.         and send it to:
  1199.      
  1200.                   Charles P. Scott / Team Alpha
  1201.                   519 Garden Springs Dr.
  1202.                   Mt. Sterling, KY  40353
  1203.      
  1204.                   Or via Compuserve: 76556,3335
  1205.      
  1206.      
  1207.         USER NAME____________________________________________________
  1208.      
  1209.         COMPANY  ____________________________________________________
  1210.      
  1211.         ADDRESS  ____________________________________________________
  1212.      
  1213.                  ____________________________________________________
  1214.      
  1215.                  ____________________________________________________
  1216.      
  1217.      
  1218.      
  1219.         PHONE # (optional) __________________________________________
  1220.      
  1221.      
  1222.      
  1223.         Equipment type, configuration and operating system
  1224.      
  1225.           ___________________________________________________________
  1226.      
  1227.           ___________________________________________________________
  1228.      
  1229.         Estimate of your computer skill level
  1230.      
  1231.           ___________________________________________________________
  1232.      
  1233.         How you obtained a copy of ENVSIZE
  1234.      
  1235.           ___________________________________________________________
  1236.      
  1237.         Comments and suggested enhancements
  1238.      
  1239.           ___________________________________________________________
  1240.      
  1241.           ___________________________________________________________
  1242.      
  1243.           ___________________________________________________________
  1244.      
  1245.  
  1246.  
  1247.  
  1248.  
  1249.                                         19
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.