Sign in to follow this  
Followers 0
kor

[solved] My For Next loop keeps starting over

4 posts in this topic

#1 ·  Posted (edited)

_AD_Open()
If $bDebug = True Then _GUI() ; run gui if debug mode is true
_Format($sCSV) ; format csv file
For $i = 0 To UBound($aInput) - 1 ; run broker loop
    If $bDebug = True Then $iBarCount = 0 ; reset main progress bar back to zero
    _Broker()
    If $bDebug = True Then
        $iStep += 100 / (UBound($aInput, 1) - 1) ; step progress bar each loop by number of rows divided by 100
        GUICtrlSetData($hBulkBar, $iStep)
    EndIf
Next
_AD_Close()

I'm not sure why. It's just a simple loop but it will start at the bottom, and it only gets 2 rows into things and just starts over and over and over.

If you need the ENTIRE script let me know but I'd rather not post the whole things. It's hundreds of lines and I'd prefer now to have to go through it and remove all the confidential info.

Edited by kor

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

is $i a local variable?

if _Broker() modifies $i and $i just happens to be global that could cause a infinite loop.

Also report the value of UBound($aInput).

You said it does 2 rows, do you mean $i= 1 when it starts the looping over. I really don't know, but that's how i'd debug the bastard.

remark the _Broker(). and report $i by placing this line in the loop

;_Broker()
consolewrite("$i= "&$i&@lf)
Edited by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

Hello kor,

Your provided example appears to have no problems in it. The problem must be somewhere else. But with so little to go on its hard to even guess what it could be.

The only 'stab in the dark' I have is a question of wether your variable $i is declared globally somewhere? If so, does your function '_Broker()' also have use for the variable $i?


My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

Yes, the Broker function reads $i in various parts. I fixed things by just moving the For Next loop inside the Broker function and running it there. Solved the problem. Thanks.

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