Jump to content

Progress Do...Until


Recommended Posts

I have to use a Do...Until instead of a For...Next for a particular progress bar. Problem is, it doesn't seem to be working correctly. I'm using it like this:

Do
        GUICtrlSetData($GasStationloadProgress, $MeterProgress/$x*100)

    Until $MeterProgress = $x

The "$MeterProgress" is the incremental number that will end at the "$x" point. It has to be, as far as I see, a Do...Until, because the incremental increase is not a steady increase based on an internal function. There are other things within this loop function that are based on things that is not suitable to use a For...Next function. So why can't I get a value from the data to be set like this, but the value will appear if I do a For...Next style? Am I trying to set the data incorrectly since I'm doing a Do...Until?

Link to comment
Share on other sites

I have to use a Do...Until instead of a For...Next for a particular progress bar. Problem is, it doesn't seem to be working correctly. I'm using it like this:

Do
        GUICtrlSetData($GasStationloadProgress, $MeterProgress/$x*100)

    Until $MeterProgress = $x

The "$MeterProgress" is the incremental number that will end at the "$x" point. It has to be, as far as I see, a Do...Until, because the incremental increase is not a steady increase based on an internal function. There are other things within this loop function that are based on things that is not suitable to use a For...Next function. So why can't I get a value from the data to be set like this, but the value will appear if I do a For...Next style? Am I trying to set the data incorrectly since I'm doing a Do...Until?

The only difference between Do/Until and While/WEnd is when the loop control condition is tested. The snippet of code you have shown is not the problem, and will work in either kind of loop. You problem is with code you have not shown here. What does "...doesn't seem to be working correctly" mean, exactly? What changes $MeterProgress?

Post a short reproducer script that just shows a progress bar updating correctly with While/WEnd, but not with Do/Until. I suspect you won't be able to do it, and in the process of trying will discover what the real problem was. (Happens to me all the time!)

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Sorry, I didn't realize that I didn't post what is actually updating the number in the script, so I'll just put the whole loop with comments....also, I can't use the progress on/set/off, because the progress meter is part of a GUI...at least I believe I can't use it that way. Here is a better example of the looping portion.

;$x is a variable number read from the site that denotes the completion of the process
;$MeterProgress is the visual denotation of the progress of the sites process

    Do
        ;Replace unwanted text from site and put it on GUI
        $Progress = StringReplace(_IEPropertyGet($Coor_Progress, "innertext"), "lines processed", @CRLF & "Station" & @CRLF & "Loaded")

        ;Replace unwanted text from site and put it on GUI
        $Progress = StringReplace(StringReplace($Progress, "(", ""),")","");Get rid of the original brackets
        ControlSetText ( $AppTitle & " - Station", "Load", $Array[25][0], $Progress)
    
        ;Get the incremental number, Replace unwanted text from site and put it on GUI(To show increases)
        $MeterProgress = StringTrimLeft(StringLeft ( _IEPropertyGet($Coor_Progress, "innertext"),StringInStr ( _IEPropertyGet($Coor_Progress, "innertext"), " ", "", 1 )),1)

        ;Set the incremental number for the progress and get the updated one in each loop from reading the site
        GUICtrlSetData($StationloadProgress, $MeterProgress/$x * 100)
        ConsoleWrite("looping and waiting for:  " & $MeterProgress & @CRLF)
        Sleep(50)
    Until $MeterProgress = $x

So what is happening is the value of "$MeterProgress/$x * 100" is not changing/calculating. It is staying at "0". But I know "$MeterProgress" is being read, because if I put that alone in a conolewrite, it shows the number increasing. So basically it looks like the number just isn't calculating and increasing when I put it in the GUICtrlSetData.

Edited by Champak
Link to comment
Share on other sites

Two things:

1. You explain in a comment where $x comes from, but I don't see any checking that it's valid. You mention specifically testing $MeterProgress, but not $x. Are you sure $x is valid while the loop is running?

2. Since the value of $MeterProgress is being extracted with String functions, you should use Number() on it before doing math with the value.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...