Jump to content

Recommended Posts

Posted (edited)

Alright, currently I'm trying to merge two loops:

 

Local $aArray[99][13]

For $iLoop = 1 to 100
    $aArray[$iLoop - 1][0] =  RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration", $iLoop)
    If @error <> 0 Then
        ReDim $aArray[$iLoop - 1][13]
        ExitLoop
    EndIf
Next

For $iLoop1 = 0 to UBound($aArray, 1) - 1
    For $iLoop2 = 1 to 12
        $aArray[$iLoop1][$iLoop2] = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\" & $aArray[$iLoop1][0], $iLoop2)
        If @error <> 0 Then ExitLoop
    Next
Next

 

into one. Here's what I have so far:

 

Local $aArray[99][13]

For $iLoop1 = 0 to UBound($aArray, 1) - 1
    For $iLoop2 = 0 to 12
        ConsoleWrite("Loop1 = " & $iLoop1 & ", Loop2 = " & $iLoop2 & @CRLF)
        If $iLoop2 = 0 Then
            $aArray[$iLoop1][0] =  RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration", $iLoop1 + 1)
            If @error <> 0 Then
                ReDim $aArray[$iLoop1 + 1][13]
                ExitLoop
            EndIf
        Else
            $aArray[$iLoop1][$iLoop2] = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\" & $aArray[$iLoop1][0], $iLoop2)
            If @error <> 0 Then ExitLoop
        EndIf
    Next
Next

And it keeps error-ing out trying to exceed the dimension range of the array. Does the Loop not recheck the size of the array after the original check or am I doing something else wrong.

 

Thanks.

Edited by rcmaehl

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

Herp derp, I'm an idiot. Fixed it:

Local $aArray[99][13]

For $iLoop1 = 0 to UBound($aArray, 1) - 1
    For $iLoop2 = 0 to 12
        ConsoleWrite("Loop1 = " & $iLoop1 & ", Loop2 = " & $iLoop2 & @CRLF)
        If $iLoop2 = 0 Then
            $aArray[$iLoop1][0] =  RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration", $iLoop1 + 1)
            If @error <> 0 Then
                ReDim $aArray[$iLoop1][13]
                ExitLoop 2
            EndIf
        Else
            $aArray[$iLoop1][$iLoop2] = RegEnumKey("HKLM\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Configuration\" & $aArray[$iLoop1][0], $iLoop2)
            If @error <> 0 Then ExitLoop
        EndIf
    Next
Next

 

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

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
×
×
  • Create New...