Jump to content

[SOLVED] - End Loop at the end of an Array


Recommended Posts

Hello All,

I have a script , related to ()which I am having trouble with.

This script, reads an array created. It first reads R1C1, copies the account#, paste it on a web form, updates the webpage, goes back to the array, and chooses the next available account number (R2C1). My problem is, once it reaches the end of the array, it begins at R1C1, and goes through the entire process in an infinite loop. How can I get it to end at the last row? Please keep in mind, the array is dynamic and can end at R8C1 or R1000C1. The total of account numbers vary daily.

I am pretty sure it is something silly I have in my script (attached). I've been trying to figure this out for the last 2 days.

Any help would be appreciated.

$i=1
Do
    $i=$i+1     
    For $r=1 To UBound($aArray1,1)-1
        $o_frame = _IEFrameGetObjByName ($oIE, "launcher")
        $oFrameB = _IEFrameGetObjByName($oIE, "target" )
        $oFrameC = _IEFrameGetObjByName($oFrameB, "results")
        $o_Input1 = _IEGetObjById($oFrameC, "SaProperty.NewHndlgCd"); either BWK-SANFR or BWK-BOSTN
        $o_Input2 = _IEGetObjById($oFrameC, "SaProperty.AcctNbr")
        Sleep (500)
        _IEFormElementOptionselect ($o_Input1, "BWK-BOSTN" , 1, "byText") ; either BWK-SANFR or BWK-BOSTN
        Sleep (2000)
    For $c=1 to UBound($aArray1,2)-1
        $aVariable = $aArray1[$r][$c]  
        $Account = ($aVariable)     
        _IEFormElementSetValue ($o_Input2, $Account)
        
Sleep (1000)
 
$oInputs1 = _IETagNameGetCollection ($oFrameC, "input")
 
Sleep (1000)
 
    For $oInput1 In $oInputs1
    If $oInput1.value = "Submit" Then
        ExitLoop
    EndIf
    Next
 
Sleep (500)
_IEAction($oInput1, "click")
 
Sleep (5000)
WinActivate ("Sagent WebLink - Windows Internet Explorer")
Sleep (1000)
_IELinkClickByIndex ($o_frame, 0);Update Customer Link
Sleep (2000)
     Next
    Next
Until $i = 5
Exit
Edited by Malpario
Link to comment
Share on other sites

I don't believe it's an infinite loop, it just repeats 5 times due to you using a Do loop.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

That was one of my attempts to stop it from an infinite loop, however, it hits 5 times and continues. It is like the energizer bunny, just keeps going.

While we are on the topic, (1) thank you for the quick response, (2) do you believe there is a way to create a gui, or an inputbox, where someone enters a number, and this number controls how many times this script loops? That may be an easier solution, seeing as the number of rows in my array will differ day to day. However, this may be a topic for the GUI Forum.

Any other hlp would be appreciated.

tldr - script continues to loop even after 5 times.

Link to comment
Share on other sites

This will ask for input

$value = InputBox("Value", "Enter value", "0")

Then $i will count how many times, as you coded, and when counts the same number the user inputed it stops

Until $i = $value

Edit:

To slow... Thats what you get for being on the phone with your gf for a half hour...

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

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...