Jury Posted November 25, 2015 Share Posted November 25, 2015 Is there a simple way to convert the results of a For ... In loop such as in the example given for _IELinkGetCollection (below) into an array? I want to sort and then delete duplicates of the resultant links before I navigate to them. ; Open browser with basic example, get link collection, ; loop through items and display the associated link URL references #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IE_Example("basic") Local $oLinks = _IELinkGetCollection($oIE) Local $iNumLinks = @extended Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt) Link to comment Share on other sites More sharing options...
Gianni Posted November 25, 2015 Share Posted November 25, 2015 one of possible ways; Open browser with basic example, get link collection, ; loop through items and display the associated link URL references #include <IE.au3> #include <MsgBoxConstants.au3> #include <array.au3> Local $oIE = _IE_Example("basic") Local $oLinks = _IELinkGetCollection($oIE) ; Local $iNumLinks = @extended Local $sTxt ; = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CR Next ; MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt) $sTxt = StringTrimRight($sTxt, 1) ; remove last @cr Local $aArray = StringSplit($sTxt, @CR, 3) ; from string to array $aArray = _ArrayUnique($aArray, 0, 0, 0, $ARRAYUNIQUE_NOCOUNT) ; remove duplicates _ArraySort($aArray) ; sort the array _ArrayDisplay($aArray) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Jury Posted November 25, 2015 Author Share Posted November 25, 2015 Chimp,Two things I can't find any mention of the flag $ARRAYUNIQUE_NOCOUNT and if I set this to 0 or 1 no array is displayed (or perhaps created?)Thanks anyway Link to comment Share on other sites More sharing options...
Gianni Posted November 25, 2015 Share Posted November 25, 2015 I'm using last AutoIt v 3.3.14.2.$ARRAYUNIQUE_NOCOUNT is set to 0, meaning don't return count in first element of the array.try to use a new variable to store the "ArrayUnque" array; Open browser with basic example, get link collection, ; loop through items and display the associated link URL references #include <IE.au3> #include <MsgBoxConstants.au3> #include <array.au3> Local $oIE = _IE_Example("basic") Local $oLinks = _IELinkGetCollection($oIE) ; Local $iNumLinks = @extended Local $sTxt ; = $iNumLinks & " links found" & @CRLF & @CRLF For $oLink In $oLinks $sTxt &= $oLink.href & @CR Next ; MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt) $sTxt = StringTrimRight($sTxt, 1) ; remove last @cr Local $aArray = StringSplit($sTxt, @CR, 3) ; from string to array local $aArray2 = _ArrayUnique($aArray, 0, 0, 0, 0) ; remove duplicates _ArraySort($aArray2) ; sort the array _ArrayDisplay($aArray2) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Jury Posted November 25, 2015 Author Share Posted November 25, 2015 Thanks again Chimp - it works without using the ArrayUnique line so I'll work on fixing that (I've used it before without a poblem somewhere) 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