bas7advr.hlp (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.
ENVIRON Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
The ENVIRON statement modifies or adds a parameter in the DOS or OS/2
environment-string table.
 
ENVIRON stringexpression$
    ■ stringexpression$ has one of these forms:
 
        parameterID=text
              or
        parameterID text
 
          parameterID    The name of the environment parameter (such as
                         PATH or PROMPT).  The parameterID must contain
                         all uppercase letters.
          text           The new parameter text.
 
    ■ Everything to the left of the equal sign or space is assumed to be a
      parameter; and everything to the right, text.
    ■ The following example sets a PATH environment variable:
 
        ENVIRON "PATH=C:\CLIENTS;C:\RATES"
 
    ■ If parameterID did not previously exist in the environment-string
      table, it is appended to the end of the table. If parameterID exists
      in the table when the ENVIRON statement is executed, it is deleted
      and the new parameterID is appended to the end of the table.
    ■ If text is a null string ("") or a semicolon (";"), the existing
      parameter is removed from the environment-string table and the
      remaining body of the table is compressed.
 
Important
    ■ You cannot increase the size of the environment-string table when
      using the ENVIRON statement. This means that before you can add a new
      environment variable or increase the size of an existing environment
      variable, you must first delete or decrease the size of existing
      environment variable(s).
    ■ BASIC generates the error message, "Out of memory" when no more space
      can be allocated to the environment-string table. The amount of free
      space in the table is usually quite small.
    ■ The parameterID must contain all uppercase letters. For example:
 
        This statement              Has this effect:
        ═══════════════════════     ═════════════════════════
        ENVIRON "PATH=C:ALES"       Changes the path.
 
        ENVIRON "path=C:ALES"       Does not change the path (it creates
                                    a new environment variable not
                                    usable by the operating system).
 
Usage Notes
    ■ DOS or OS/2 discards the environment-string table modified by this
      function when your program ends. The environment-string table is then
      the same as it was before your program ran.
    ■ You can use this statement to change the PATH parameter for a
      "child" process (a program or command started by a SHELL statement)
      or to pass parameters to a child by creating a new environment
      variable.
    ■ If the parameterID did not previously exist in the environment-
      string table, it is appended to the end of the table. If a
      parameterID exists in the table when the ENVIRON statement is
      executed, it is deleted and the new parameterID is appended to the
      end of the table.
    ■ If the text is a null string ("") or a semi-colon (";"), the
      existing parameter is removed from the environment-string table and
      the remaining body of the table is compressed.