Sign in to follow this  
Followers 0
rcmaehl

[Solved] Trying to Merge two loops. I know I'm doing something wrong

2 posts in this topic

#1 ·  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


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites



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


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Eli_jahbot
      By Eli_jahbot
      My esteemed Autoits I need your help once again.
      I'm trying to figure out how to create a loop that gets 1 value from an array and repeats until each value from the array has been used. I have never used arrays before and I know once I learn more things should get easier for me. 
      Here is what Im trying to do:
      -Have an array of values that determine what application i log into. ex: app1, app2, app3, app4 etc.
      -Have a loop that repeats a process sequentially using each value in the array to finish the process for each app1, app2, app 3 and so forth. I have 30 apps that I need to update on a regular basis and getting this sorted out is what I perceive to be the best way to do it.
      Here is my feeble attempt that obviously fails:
      #include <msgboxconstants.au3>
      #include <Constants.au3>
      #include <array.au3>
      Login()
      Func Login()
          local $array[30] = ["10", "11", "12",etc etc]
          ;;Local $site = InputBox("ERx Site","What site do you want to login as?","","")
          Local $userid = InputBox("ERx Login", "What is your username?", "", "")
          Local $Passwd = InputBox("Security Check", "Enter your UAT password.", "", "*")
      for $1 = 1 to 30(I need to do the same steps in 30 different apps)
      run("Z:launch.exe")
      WinWaitActive("Input")
      Send (Sequential ARRAY VALUE HERE)
      Send("{ENTER}")
      WinWaitActive("window")
      Send($userid)
      Send("{TAB}")
      send($Passwd)
      Send("{ENTER}")
      WinWaitActive("[CLASS:SunAwtDialog]")
      Sleep(500)
      WinClose("Home Page")
      Next
      EndFunc
       
      your help is greatly appreciated.
      Thanks for your time
    • Patryk
      By Patryk
      Dear Colleagues,
      I have no idea how to refer to style.display in my loop. There is a button like: 
      <input name="ctl00$bodyPlaceholder$btnFecharProcessamento" class="button" id="bodyPlaceholder_btnFecharProcessamento" style="display: none;" onclick="FecharJanelaProcessamento();return false;" type="submit" value="Fechar"> I want it to be clicked as soon as button's style change from style="display: none;" to  style= ="display: inline-block;" 
      This is what I got, but it's not working...
      Func GetButtons() $oButtons = _IEGetObjByName($oForm,"ctl00$bodyPlaceholder$btnFecharProcessamento",-1) $i = 0 While $i <> 1 For $oBtn In $oButtons If _IEFormElementGetValue($oBtn) = "Fechar" And $oBtn.document.style.display = "display: inline-block;" Then $i = 1 _IEAction($oBtn, "focus") _IEAction($oBtn, "click") ExitLoop EndIf Next WEnd EndFunc  
      I will really appreciate if you could help me with these loop!
    • 9252Survive
      By 9252Survive
      Hi All, 
       
      I am fairly new to AutoIT and I am still trying to learn, I have been using _FileListToArray to list all the files with a particular extension in an array and then loop through it for operation  (   For $i = 1 To UBound($FileArray) - 1).
      So far this has been working fine. But I am not able to figure out a problem that I have; what if I have 50 files but I only want to loop through first 10 files and then next ten and so on?  Or rather I should say, how I can I only feed max 10 files to the array at a time when I do _FileListToArray regardless of the total number of files in the folder?
      Any insight/help will be much appreciated 
    • Nareshm
      By Nareshm
      How to repeat my script when my control class does not match ?
       
      My Script : winActivate ( " PS :: Version - 2.2.0.0  - [PS Bill]")                   ControlClick ( "PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]")                   ControlSend(" PS :: Version - 2.2.0.0  - [PS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")                   WinActive ("Verification Number Entry ::")                   ControlClick("Next >", "","[NAME:btnNext]") ;if   >>>> Control <<<<  does not match repeat my script, ;if match exit script  

      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468
    • SkysLastChance
      By SkysLastChance
      I am not sure why I am getting the this error on my second pass of the code.
      1 - $oWorkbook is not an object or not a workbook object
      Any help or advice on my code appreciated. 
      #include <Excel.au3> #include <Array.au3> #include <MsgBoxConstants.au3> Global $sExcelFile1 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)") Global $sExcelFile2 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)") Global $vRow = 2 If FileExists($sExcelFile2) Then Global $oExcel2 = _Excel_Open () $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2) EndIF If FileExists($sExcelFile1) Then Global $oExcel1 = _Excel_Open () $oExcel1 = _Excel_BookOpen($oExcel1,$sExcelFile1,Default,Default,"2007") EndIF $oRead = _Excel_RangeRead ($oExcel2,"Untitled","A2",3) $oFind = _Excel_RangeFind ($oExcel1,$oRead,"E4:FD92",Default,$xlWhole) $Clip = _ArrayToClip($oFind,"",0,0,"",2,2) Send("{ScrollLock Off}") $hWnd = WinWait("[CLASS:XLMAIN]") ControlSend($hWnd, "", "", ("^g")) WinWait("[CLASS:bosa_sdm_XL9]") ; Go To ControlSend($hWnd, "", "", ("^v")) ControlSend($hWnd, "", "", ("{Enter}")) ControlSend($hWnD, "", "", "{Down " & $vRow & "}") Do $oTime = _Excel_RangeRead ($oExcel2,"Untitled","B2",3) If @error Then Exit MsgBox(0, "Error", "Error" & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox(0,"Test",$oTime) IF $oTime = "7:10:00 AM" Then $oCalls1 = _Excel_RangeRead ($oExcel2,Default,"C" & $vRow,3) $oCalls2 = _Excel_RangeRead ($oExcel2,Default,"D" & $vRow,3) ControlSend($hWnd, "", "", $oCalls1) ControlSend($hWnd, "", "", ("{RIGHT}")) ControlSend($hWnd, "", "", $oCalls2) $vRow = $vRow + 1 ContinueLoop Else $vRow = $vRow + 1 EndIf Until $vRow = 4 1.xlsm
      2.xlsx