Jump to content

Reading Registry to multi D array


Recommended Posts

This is my current code, there has to be a more efficient way to do it? I would prefer to read the registry directly into the final array.

$OneRead = RegRead($RegLocation, "One")
    Global $Appt_One_Array = StringSplit( $OneRead, @LF )

    $TwoRead = RegRead($RegLocation, "Two")
    Global $Appt_Two_Array = StringSplit( $TwoRead, @LF )

    $ThreeRead = RegRead($RegLocation, "Three")
    Global $Appt_Three_Array = StringSplit( $ThreeRead, @LF )

    $FourRead = RegRead($RegLocation, "Four")
    Global $Appt_Four_Array = StringSplit( $FourRead, @LF )

    $FiveRead = RegRead($RegLocation, "Five")
    Global $Appt_Five_Array = StringSplit( $FiveRead, @LF )
    
    Dim $Input_Array[UBound($Appt_One_Array)][5]
    For $i = 0 To UBound($Appt_One_Array) - 1
        $Input_Array[$i][0] = $Appt_One_Array[$i]
        $Input_Array[$i][1] = $Appt_Two_Array[$i]
        $Input_Array[$i][2] = $Appt_Three_Array[$i]
        $Input_Array[$i][3] = $Appt_Four_Array[$i]
        $Input_Array[$i][4] = $Appt_Five_Array[$i]
    Next
Edited by Champak
Link to comment
Share on other sites

$keys = "One;Two;Three;Four;Five"
$aKeys = StringSplit($keys, ";")

Dim $Input_Array[$aKeys[0]][5]

For $X = 1 to $aKeys[0]
    $Read = RegRead($RegLocation, $aKeys[$X])
    Global $Appt_Array = StringSplit($Read, @LF )
    
    For $Y = 1 to $Appt_Array[0]
        $Input_Array[$X-1]][$Y-1] = $Appt_Array[$Y]
    Next
Next

Edited by weaponx
Link to comment
Share on other sites

Thanks, had to make a couple changes...forgot to mention these are REG_MULTI_SZ

$keys = "One;Two;Three;Four;Five"
$aKeys = StringSplit($keys, ";")

$OneRead = RegRead($RegLocation, "One")
$Appt_Array = StringSplit( $OneRead, @LF )

Global $Input_Array[$Appt_Array[0]][$aKeys[0]]

For $X = 1 to $aKeys[0]
    $Read = RegRead($RegLocation, $aKeys[$X])
    $Appt_Array = StringSplit($Read, @LF )
    For $Y = 1 to $Appt_Array[0]
        $Input_Array[$Y-1][$X-1] = $Appt_Array[$Y]
    Next
Next
Edited by Champak
Link to comment
Share on other sites

Thanks, had to make a couple changes...forgot to mention these are REG_MULTI_SZ

$keys = "One;Two;Three;Four;Five"
$aKeys = StringSplit($keys, ";")

$OneRead = RegRead($RegLocation, "One")
$Appt_Array = StringSplit( $OneRead, @LF )

Global $Input_Array[$Appt_Array[0]][$aKeys[0]]

For $X = 1 to $aKeys[0]
    $Read = RegRead($RegLocation, $aKeys[$X])
    $Appt_Array = StringSplit($Read, @LF )
    For $Y = 1 to $Appt_Array[0]
        $Input_Array[$Y-1][$X-1] = $Appt_Array[$Y]
    Next
Next
Why did you add the top two lines back in?

$OneRead = RegRead($RegLocation, "One")
$Appt_Array = StringSplit( $OneRead, @LF )

They do nothing. The result is overwritten on the first loop.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...