n4n0 Posted March 20, 2017 Share Posted March 20, 2017 I have been trying to move around the values etc, but nothing seems to be working. In this case $i goes up to 18, but I want it to go up to $vLoop1 * $vLoop2 which is 10. Thank you. Global $vLoop1, $vLoop2, $i While $vLoop2 <= 2 $vLoop1 = 0 $vLoop2 += 1 While $vLoop1 <= 5 $i += 1 MsgBox(0, "", $i) $vLoop1 += 1 WEnd WEnd Link to comment Share on other sites More sharing options...
RTFC Posted March 20, 2017 Share Posted March 20, 2017 Uninititalised counters will start at 0, not 1. Better explicitly define what you want your loops to do. Global $i=0 For $vLoop2=1 to 2 Step 1 For $vLoop1=1 to 5 Step 1 $i+=1 MsgBox(0,"",$i) Next Next My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
n4n0 Posted March 20, 2017 Author Share Posted March 20, 2017 8 minutes ago, RTFC said: Uninititalised counters will start at 0, not 1. Better explicitly define what you want your loops to do. Global $i=0 For $vLoop2=1 to 2 Step 1 For $vLoop1=1 to 5 Step 1 $i+=1 MsgBox(0,"",$i) Next Next I did something similar first, and it worked, but then I ran into problems exiting the loop, ie. if $vLoop1 value changes because of given arguments. How would I rewrite this to use While loop instead? Link to comment Share on other sites More sharing options...
Subz Posted March 20, 2017 Share Posted March 20, 2017 For loops are much better imho, not sure what you mean by "I ran into problems exiting the loop", however to do the same using While Wend you could use the following: Global $vLoop1 = 1, $vLoop2 = 1, $i = 0 While $vLoop2 <= 2 $vLoop2 += 1 While $vLoop1 <= 5 $i += 1 ConsoleWrite($i & @CRLF) $vLoop1 += 1 WEnd $vLoop1 = 1 WEnd Link to comment Share on other sites More sharing options...
RTFC Posted March 20, 2017 Share Posted March 20, 2017 5 hours ago, n4n0 said: I ran into problems exiting the loop ExitLoop doesn't work for you? My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O 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