fraizor Posted July 19, 2023 Share Posted July 19, 2023 Hello I have a huge loop (around 100k) I was wondering if there is a way to do a function every 1k loops i can hardcode the number in IF condition but this looks silly ... any ideas ? AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
Danp2 Posted July 19, 2023 Share Posted July 19, 2023 Have you looked at using the Mod() function? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
fraizor Posted July 19, 2023 Author Share Posted July 19, 2023 Actually yes , but my brain crashed Like i can imagine how mod() could help if the loop is fixed to 100k, so i could easily do mod($i, 10000) However i cant understand how this would work for dynamic loop size .... One more thing , regarding mod() is it a heavy function ? wont this waste time and CPU power to calculate mopd in every single loop ? AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
Developers Jos Posted July 19, 2023 Developers Share Posted July 19, 2023 Not sure why you are at ll worried about cpu cycles when using an interpreter scripting language! As to the Mod() function, it is simple so I am sure you will be able how to code an if that will be true each 1000 cycles. Just kick your brain in gear at try it as that takes less time than tying your question here. fraizor 1 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...
Solution fraizor Posted July 19, 2023 Author Solution Share Posted July 19, 2023 Hmmm.. I should do this: if mod($i, 10000) = 0 then myfunc() am i right ? AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! Link to comment Share on other sites More sharing options...
Developers Jos Posted July 19, 2023 Developers Share Posted July 19, 2023 10 minutes ago, fraizor said: am i right ? Did you try and did it work? 🙄 Spoiler (it won't do what you initially asked though as 1k <> 10000) fraizor 1 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...
Andreik Posted July 19, 2023 Share Posted July 19, 2023 If you are afraid of Mod() you can use a simple counter: $Counter = 0 While True If $Counter = 10000 Then $Counter = 0 MyFunc() EndIf $Counter += 1 ; rest of the code WEnd fraizor 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
fraizor Posted July 19, 2023 Author Share Posted July 19, 2023 5 minutes ago, Jos said: Did you try and did it work? 🙄 Reveal hidden contents (it won't do what you initially asked though as 1k <> 10000) Yes thank you guys , all AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF ! 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