Jump to content
Sign in to follow this  
ThomasQ

How To Sort Links, or other collections

Recommended Posts

ThomasQ

Hi!

I'm building a script to make my work a hell of a lot easier. One of the final steps is that I have to find a way to check the innertext of an url, take a specific part (in this case a number) of the text, and compere it to another one. In this case I have to sort starting with the lowest number

Example:

With this script I return the innertext, of the gotten links.

$oLinks = _IELinkGetCollection ($oIE)

Local $iLinkIndex = 16 ; Change this to the index you want

Local $iCurrentIndex = 0

For $oLink In $oLinks

$iCurrentIndex += 1

If $iCurrentIndex = $iLinkIndex Then

$klantmail = _IEPropertyGet($oLink, "innertext")

When I get these back

- ProductID: 5870729_000

- ProductID: 5870717_000

- ProductID: 5870821_000

I have to identify wich one has the lowest number, then the one after that, etc..

Anyone any good ideas??

Many Thanks in advance!!

Share this post


Link to post
Share on other sites
monoceres

Merry christmas.

#include <array.au3>



$oLinks = _IELinkGetCollection($oIE)

Local $iLinkIndex = 16 ; Change this to the index you want
Local $iCurrentIndex = 0
Local $Array[1]
For $oLink In $oLinks
    $iCurrentIndex += 1
    If $iCurrentIndex = $iLinkIndex Then
        $klantmail = StringReplace(StringReplace(_IEPropertyGet($oLink, "innertext"), "- ProductID: ", ""), "_", "")
        If UBound($Array) = 1 Then
            $Array[0] = $klantmail
        Else
            ReDim $Array[UBound($Array) + 1]
            $Array[UBound($Array) - 1] = $klantmail
        EndIf
    EndIf
Next


_ArraySort($Array)
_ArrayDisplay($Array)

>_<


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
ThomasQ

Hahah Thanks! I'll be implementing it tomorrow. Let you know how it went!

Share this post


Link to post
Share on other sites
ThomasQ

Well, tried it a couple of times, but no succes. I don't get any results when _Arraydisplays runs.. I do get the building of the array though, but somewhere there must be a little kink in the cable. I also took a good look at the innertext to be sorted, it contains 3 variables: IP* - ProductID: *******-***, where each * is a variable..

$oLinks = _IELinkGetCollection($oIE)

Local $Array[1]

For $oLink In $oLinks

$klantmail = StringReplace(StringReplace(_IEPropertyGet($oLink, "innertext"), "IP2 - ProductID: ", ""), "_", "")

If UBound($Array) = 1 Then

$Array[0] = $klantmail

Else

ReDim $Array[uBound($Array) + 1]

$Array[uBound($Array) - 1] = $klantmail

EndIf

Next

_ArraySort($Array)

_ArrayDisplay($Array)

Edited by ThomasQ

Share this post


Link to post
Share on other sites
ThomasQ

Well, this script returns 3 links, with 0 being nothing, and 1 & 2 the wanted links

$oLinks = _IELinkGetCollection($oIE)

Local $Array[1]

For $oLink In $oLinks

$klantmail = _IEPropertyGet($oLink, "innertext")

$ProductID = StringInStr($klantmail, "ProductID")

ConsoleWrite($ProductID & @CRLF)

If $ProductID = 7 Then

ReDim $Array[uBound($Array) + 1]

$Array[uBound($Array) - 1] = $klantmail

EndIf

Next

_ArraySort($Array)

_ArrayDisplay($Array)

Why does the 0 index of the array has to be clean?

Share this post


Link to post
Share on other sites
Authenticity

Recalculating the array using it's upper-bound first result to 1 instead of 0. You can make a string concatenation like:

$sString &= $klantmail & '|'

; ....
$aLinks = StringSplit(StringTrimLeft($sString, 1), '|', 2)

and the array will contain the links starting at index 0 which is the first link.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.