aghering Posted March 5, 2015 Share Posted March 5, 2015 Hi, I want to use a IF statement to check a certain value in a do.. until.. loop. the challenge is that the until value is always variable, meaning that it can be until 100, 350,177,1299 and so on. and what i want is that the IF statement is to be triggered every 10%, 20% or 50% of the until value? my question: can someone provide me a example to lead me in the good direction? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 5, 2015 Developers Share Posted March 5, 2015 Hi, I want to use a IF statement to check a certain value in a do.. until.. loop. the challenge is that the until value is always variable, meaning that it can be until 100, 350,177,1299 and so on. and what i want is that the IF statement is to be triggered every 10%, 20% or 50% of the until value? my question: can someone provide me a example to lead me in the good direction? What about you try to show something more exact and tell us what isn't working since this definition is all over the place? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MikahS Posted March 5, 2015 Share Posted March 5, 2015 (edited) I'm not sure if you've had a look at these wiki examples. But, I hope they help. Something like this: Local $c = 1 Do If $c / 2 = 4 Then ConsoleWrite("4") ElseIf $c / 2 = 8 Then ConsoleWrite("8") ElseIf $c / 2 = 10 Then ConsoleWrite("10") EndIf $c += 1 Until $c = 21 MsgBox(0, "", "We're done") Edited March 5, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 $limit = 7 $x = 0 do ;some stuff If $x = round(($limit)/2) Then Msgbox(0, '' , $x & ", you have reached 50%") $x+=1 consolewrite($x & @CRLF) until $x = $limit ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
aghering Posted March 5, 2015 Author Share Posted March 5, 2015 b= IniReadSection ($Config, "Records") $Range= $b[0][0] _ConsoleWrite ("Debug: Number of Records Found" & $Range, 3) $j= 0 Do $a = IniRead($Config, "Records", "Record" & $j, "0|0") $aArray = StringSplit($a, "|") MouseMove($aArray[1],$aArray[2],1) _ConsoleWrite ("Debug: Location X: " & $aArray[1] &"| Y: "& $aArray[2], 4) $StopLoop = _CheckNotification() If $StopLoop = 1 Then $ErrorOnWalkThrough = 1 _ConsoleWrite("Error detected", 1) ExitLoop EndIf $j = $j + 1 Until $j= $Range The code above is what i have now. But having "$StopLoop = _CheckNotification()" running on each run is lowering the performance of the script. Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 (edited) what does _checknotification do? can we see that func as well please? Edited March 5, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Solution Geir1983 Posted March 5, 2015 Solution Share Posted March 5, 2015 (edited) Do something like this? Edit: didnt read the part about the % of your loop. b= IniReadSection ($Config, "Records") $Range= $b[0][0] _ConsoleWrite ("Debug: Number of Records Found" & $Range, 3) $j= 0 $Loopcounter = 0 $DoEvery = Int($Range / 4) ;amount of loops before doing action at every 25% Do $Loopcounter += 1 $a = IniRead($Config, "Records", "Record" & $j, "0|0") $aArray = StringSplit($a, "|") MouseMove($aArray[1],$aArray[2],1) _ConsoleWrite ("Debug: Location X: " & $aArray[1] &"| Y: "& $aArray[2], 4) If Mod($Loopcounter, $DoEvery) = 0 Then $StopLoop = _CheckNotification() If $StopLoop = 1 Then $ErrorOnWalkThrough = 1 _ConsoleWrite("Error detected", 1) ExitLoop EndIf $j = $j + 1 Until $j= $Range Edited March 5, 2015 by Geir1983 Link to comment Share on other sites More sharing options...
aghering Posted March 5, 2015 Author Share Posted March 5, 2015 Thanks for the response and i'll will look in to it. @boththose this is what i have in my checknotification, i am working with a custom made application that gives notification in a fancy manner. at first i though of working with imagesearch but for performance and reliability i used pixelsearch. Func _checknotification() $aResult= IniRead($Config, "First Record", "Coordinates", "0|0") $aArray = StringSplit($aResult, "|") $aCoord = PixelSearch($aArray[1] -226, $aArray[2] -149, $aArray[1], $aArray[2] +68, 0xFDFDFF) ;Search For Selected Page $aCoordx = $aCoord[0] If @error <> 1 Then $aCoordx = $aCoord[0] $z = PixelSearch($aCoordx + 15, $aCoord[1], $aCoordx + 15, $aCoord[1], 0xFCFCFF) If @error <> 1 Then $z = PixelSearch($aCoordx + 15, $aCoord[1], $aCoordx + 15, $aCoord[1], 0xFCFCFF) If @error <> 1 Then return 1 Else _ConsoleWrite("Debug: PixelSearch not found a match on third search", 3) return 0 EndIf Else _ConsoleWrite("Debug: PixelSearch not found a match on second search", 3) return 0 EndIf else return 0 EndIf Link to comment Share on other sites More sharing options...
TheSaint Posted March 5, 2015 Share Posted March 5, 2015 @AutoIteers - I know you are enthusiastic helpers and all, and that is to be encouraged and even admired. But when the OP hasn't provided code, and someone like Jos (especially) asks a question, then you really should be waiting until the OP has responded to that question. There are usually one or more good reasons for this. P.S. Jos I hope you don't mind me speaking up like this, but I have seen this happen a lot. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
aghering Posted March 5, 2015 Author Share Posted March 5, 2015 Do something like this? Edit: didnt read the part about the % of your loop. b= IniReadSection ($Config, "Records") $Range= $b[0][0] _ConsoleWrite ("Debug: Number of Records Found" & $Range, 3) $j= 0 $Loopcounter = 0 $DoEvery = Int($Range / 4) ;amount of loops before doing action at every 25% Do $Loopcounter += 1 $a = IniRead($Config, "Records", "Record" & $j, "0|0") $aArray = StringSplit($a, "|") MouseMove($aArray[1],$aArray[2],1) _ConsoleWrite ("Debug: Location X: " & $aArray[1] &"| Y: "& $aArray[2], 4) If Mod($Loopcounter, $DoEvery) = 0 Then $StopLoop = _CheckNotification() If $StopLoop = 1 Then $ErrorOnWalkThrough = 1 _ConsoleWrite("Error detected", 1) ExitLoop EndIf $j = $j + 1 Until $j= $Range Got it working with the example you provided, 1 thing i did add to your example $DoEvery = Round(Int($Range / 4), -1) ;amount of loops before doing action at every 25% PS: MOD has a unclear description in the help but knowing the question i asked its clear to me. @AutoIteers - I know you are enthusiastic helpers and all, and that is to be encouraged and even admired. But when the OP hasn't provided code, and someone like Jos (especially) asks a question, then you really should be waiting until the OP has responded to that question. There are usually one or more good reasons for this. P.S. Jos I hope you don't mind me speaking up like this, but I have seen this happen a lot. May i ask what reason(s) could that be to my question? Link to comment Share on other sites More sharing options...
iamtheky Posted March 5, 2015 Share Posted March 5, 2015 Since he responded with code in #5 that leaves you thinking Mikah and I should have not responded because Jos asked for further definition of the issue. I think I'll pass on being that refined in my forum etiquette, if a badged individual wants discussion steered or stopped they should do so with very clear instructions. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now