Function Basic Extensions Class

EnvironToVariantVector

Return the DOS Environment settings (such as "TEMP=C: \TEMP") in elements 1..N of a one-dimensional dynamic array of values.

Signature (Visual Basic / VBA)

Public Function EnvironToVariantVector( _
    ByRef rEnviron() As Variant _
    ) As Boolean

Code Example

    Assuming
       Dim avarEnv() As Variant
    for example
       EnvironToVariantVector(avarEnv()) = True
    might leave
       LBound(avarEnv) = 0
       UBound(avarEnv) = 5
       avarEnv(1) = "COMSPEC=C:\COMMAND.COM"
       avarEnv(2) = "PROMPT=$p$g"
       avarEnv(3) = "TEMP=C:\TEMP"
       avarEnv(4) = "TZ=PST8PDT"
       avarEnv(5) = "PATH=D:\WIN;D:\WIN\COMMAND;C:\DOS"

Parameters

Parameter Description
rEnviron Dynamic array of Variants into which the DOS Environment settings will be copied. The array will be re-dimensionsed as a one-dimensional array with a lower-bound of 0 (zero). The upper bound will be the number of DOS Environment settings in the array. The 0 (zero) element of the array will remain Empty and unused, so that the array can be re-dimensioned with both lower and upper bounds of 0 in case there are no DOS Environment settings. (The settings will be copied into elements 1..N of the array, but it will be dimensioned from 0..N.)

Return Value

This function always returns True.

Notes & Version History

Summary Each of the DOS Environment settings is stored in one of the elements of the dynamic array rEnviron. The dynamic array is automatically re-dimensioned so thats its upper-bound is the number of settings within the Environment. If there are no Environment settings (this is unlikely), the array will be re-dimensioned with lower AND upper bounds of 0 (zero).