ex.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$ Function and ENVIRON Statement Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example uses the ENVIRON$ function to get a copy of your current
' PATH variable. Your PATH is then changed using the ENVIRON statement.
' The program then uses the ENVIRON$ function to print out the contents
' of the environment string table. The example concludes by restoring
' your original PATH statement.
 
' Note: For this example to run, the value of your path variable must be
' longer than the new path value in the ENVIRON statement.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 CLS                                             ' Clear the screen
 DEFINT A-Z
 PATH$ = "PATH="                                 ' Initialize
 I% = 1
 OldPath$ = ENVIRON$("PATH")                     ' Get the old PATH
 ENVIRON "PATH=C:\BIN;C:\DOS;C:\BUSINESS"
 PRINT "Your current environment settings are:"  ' Display the string table
 PRINT
 DO WHILE ENVIRON$(I%) <> ""
     PRINT ENVIRON$(I%)
     I% = I% + 1
 LOOP
 ENVIRON PATH$ + OldPath$                        ' Change the PATH back
 PRINT
 PRINT "Your PATH has been restored to:"         ' Verify the change
 PRINT
 PRINT ENVIRON$("PATH")