rednaxela Posted March 25, 2021 Share Posted March 25, 2021 Hello, is there a way to skip a number in the loop? i want skip color number 3 from my array of colors. Global $color[5] = [0xB006AF,0x850485,0x5B0159,0x430045,0x39380C] For $x = 0 to 5 - 1 Local $icon = PixelSearch(254, 189,594, 503, $color[$x]) Next Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 25, 2021 Share Posted March 25, 2021 @rednaxela You should use UBound() with your array in order to avoid to write 5 in your For...Next loop, and then, if you want to skip an element in your loop, just use an If...Then with the index ($x), and if the condition is true, use ContinueLoop. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
rednaxela Posted March 26, 2021 Author Share Posted March 26, 2021 5 hours ago, FrancescoDiMuro said: @rednaxela You should use UBound() with your array in order to avoid to write 5 in your For...Next loop, and then, if you want to skip an element in your loop, just use an If...Then with the index ($x), and if the condition is true, use ContinueLoop. ; Display all the numbers for 1 to 10 but skip displaying 7. For $i = 1 To 10 If $i = 7 Then ContinueLoop ; Skip displaying the message box when $i is equal to 7. EndIf MsgBox($MB_SYSTEMMODAL, "", "The value of $i is: " & $i) Next this is what i was looking for :3 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted March 26, 2021 Share Posted March 26, 2021 @rednaxela Just to let you know, if the If statement has only one instruction, you can write that on one line, omitting the EndIf at the end, as shown in the example in the Help file. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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