# Looping through a ArrayFindall result set (part 2)

## Recommended Posts

Hi everyone

I am using _ArrayFindAll to gather a set of values, this works fine I now want to loop through that set of results to get the values from the indexes at certain positions, heres my result from arrayfindall

[0]|1

[1]|3

[2]|6

[3]|7

[4]|9

[5]|10

[6]|11

[7]|12

[8]|14

[9]|15

[10]|17

I am trying to locate the following, 1 value on its own, which would be index [0] the 1 as the next index is not a sequential number (not 2, its a 3) this one is easy as I use

;find last single

\$sequencehistory[\$i][0] = \$a[0]

Now I don't get what I expected, I am now looking for 2 sequntial values, IE 3,4 or 8,9 in the above case it is indexes [2] & [3] which are 6 & 7

This is what I came up with but its not working

\$j = 0

Do

;find last double

If \$a[\$j]+1 = \$a[\$j+1] Then

\$sequencehistory[\$i][1] = \$a[\$j]

\$j = 119; if we find 2 in a row get out of here

EndIf

\$j = \$j+1

Until \$j = 120 Or UBound(\$a)-1

Lastly, I am looking for 3 in a row (9,10,11 in the above data set) using this in the same Do loop

If \$a[\$j]+1 = \$a[\$j+1] And \$a[\$j]+2 = \$a[\$j+2] Then

I hope its a simple thing I am overlooking and I hope I have explained it well enough for someone more experienced to see the error/s

Edit; sorry should have said for the 2 seq I want the value of the index that starts the seq and the 3 seq also the start value of the index it was found at

Edited by Phaser
##### Share on other sites

Issue solved, it appears I can't run a Do loop within another Do loop, the above 3 Do loops were running within one main Do loop, I have solved it by changing the Do loops to While loops and it all works as expected now.

##### Share on other sites

• Moderators

Phaser,

it appears I can't run a Do loop within another Do loop

Of course you can:

```\$i1 = 0
ConsoleWrite("Loop 1 = " & \$i1 & @CRLF)
Do
\$i2 = 0
Do
\$i2 += 1
ConsoleWrite(@TAB & "Loop 2 = " & \$i2 & @CRLF)
Until \$i2 = 3

\$i1 += 1
ConsoleWrite("Loop 1 = " & \$i1 & @CRLF)
Until \$i1 = 3```

You might not be able to, but that is a problem in your coding - not one of AutoIt's making.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...