Jump to content

[HELP]Problem with Array variable


n8gk
 Share

Recommended Posts

Hello everybody, I'm new with AutoIt and on this forum aswell... And I'm really interested in learning all this stuff. BUT I've run in some problems with the Array variable. And I really can use some help. Can someone guide me into the right way..?

How can I get the value of "one" specific item from an array?

I have an array with several useful and useless links. But I only want the useful ones.

All the useful links start with hxxp://www.webpage.com/images/.

How can only pick the useful links out of the array?

CODE

$aLinks = _FFLinksGetAll()

$sSearch = "hxxp://www.webpage.com/images/"

$iIndex = _ArraySearch($aLinks, $sSearch)

_ArrayDisplay($iIndex)

Thanks in advance

Edited by n8gk
Link to comment
Share on other sites

_ArraySearch() returns only the index of the match if successful and not an array type. You can use a second array variable and build a loop and walk the array. Example:

#include <Array.au3>
#include <FF.au3>

_FFConnect()
_FFTabAdd('http://www.google.com/')
Dim $avLinks = _FFLinksGetAll()
Dim $avFilter[1][1] = [[1]]
If IsArray($avLinks) Then 
    
    For $i = 0 To UBound($avLinks)-1
        If StringInStr($avLinks[$i][0], 'images') Then
            ReDim $avFilter[$avFilter[0][0]+1][1]
            $avFilter[$avFilter[0][0]][0] = $avLinks[$i][0]
            $avFilter[0][0] += 1
        EndIf
    Next
    $avFilter[0][0] -= 1
EndIf

If $avFilter[0][0] Then _ArrayDisplay($avFilter)
_FFDisConnect()
Link to comment
Share on other sites

Hello everybody, I'm new with AutoIt and on this forum aswell... And I'm really interested in learning all this stuff. BUT I've run in some problems with the Array variable. And I really can use some help. Can someone guide me into the right way..?

How can I get the value of "one" specific item from an array?

I have an array with several useful and useless links. But I only want the useful ones.

All the useful links start with hxxp://www.webpage.com/images/.

How can only pick the useful links out of the array?

CODE

$aLinks = _FFLinksGetAll()

$sSearch = "hxxp://www.webpage.com/images/"

$iIndex = _ArraySearch($aLinks, $sSearch)

_ArrayDisplay($iIndex)

Thanks in advance

A RegExp might work great, Depends on what's in between the links, Here is some code if its just a space

#Include <Array.au3>
$teststr = 'hxxp://www.webpage.com/images/link1.url http://www.webpage.com/images/badlink1.url hxxp://www.webpage.com/images/link2.url hxxp://www.webpage.com/images/link3.url'

$aLinks = StringRegExp($teststr ,'(hxxp://[^\s]*)',3)

_ArrayDisplay($aLinks)
Link to comment
Share on other sites

Hello everybody, I'm new with AutoIt and on this forum aswell... And I'm really interested in learning all this stuff. BUT I've run in some problems with the Array variable. And I really can use some help. Can someone guide me into the right way..?

How can I get the value of "one" specific item from an array?

I have an array with several useful and useless links. But I only want the useful ones.

All the useful links start with hxxp://www.webpage.com/images/.

How can only pick the useful links out of the array?

CODE

$aLinks = _FFLinksGetAll()

$sSearch = "hxxp://www.webpage.com/images/"

$iIndex = _ArraySearch($aLinks, $sSearch)

_ArrayDisplay($iIndex)

Thanks in advance

If you search image-srcs then you can do this:

$aArray = _FFXPath("//img[contains(@src,'hxxp://www.webpage.com/images/')]","",6)
_ArrayDisplay($aArray)oÝ÷ Úåy,jëh×6$aArray = _FFXPath("//a[contains(@href,'hxxp://www.webpage.com/images/')]","",6)
_ArrayDisplay($aArray)
Link to comment
Share on other sites

Wow thank you very much guys. Very appreciate!!!

The one from Authenticity worked immediately.

#include <Array.au3>
#include <FF.au3>

_FFConnect()
_FFTabAdd('http://www.google.com/')
Dim $avLinks = _FFLinksGetAll()
Dim $avFilter[1][1] = [[1]]
If IsArray($avLinks) Then
   
    For $i = 0 To UBound($avLinks)-1
        If StringInStr($avLinks[$i][0], 'images') Then
            ReDim $avFilter[$avFilter[0][0]+1][1]
            $avFilter[$avFilter[0][0]][0] = $avLinks[$i][0]
            $avFilter[0][0] += 1
        EndIf
    Next
    $avFilter[0][0] -= 1
EndIf

If $avFilter[0][0] Then _ArrayDisplay($avFilter)
_FFDisConnect()oÝ÷ Ø­#]²×©¥çZÁ¬®²)ම§Á´ e~éܶ*'çºÇ­éâ·lëmx&¢·¥y,¶§ë,që¯#NXýë"EM¦åyjâµäèºÚÈ&®±é²­ë.Û0Y[zj+y§º¶­z'Èv(wg£7ögÚr)àjz-êé®åzdáyªëk'béììj· zÛb    Z®«)ȨÎQ£5Ð*%±h^­çâÖ°k*+櫬ÊÚ zÖ¥Ö­iúè]¢[.׫Ô*%ºÚÈ8¬¦V²h.®

I'm not asking you to write the whole code down. To guide me into the right ways.

Thank you.

Link to comment
Share on other sites

Wow thank you very much guys. Very appreciate!!!

The one from Authenticity worked immediately.

#include <Array.au3>
#include <FF.au3>

_FFConnect()
_FFTabAdd('http://www.google.com/')
Dim $avLinks = _FFLinksGetAll()
Dim $avFilter[1][1] = [[1]]
If IsArray($avLinks) Then
   
    For $i = 0 To UBound($avLinks)-1
        If StringInStr($avLinks[$i][0], 'images') Then
            ReDim $avFilter[$avFilter[0][0]+1][1]
            $avFilter[$avFilter[0][0]][0] = $avLinks[$i][0]
            $avFilter[0][0] += 1
        EndIf
    Next
    $avFilter[0][0] -= 1
EndIf

If $avFilter[0][0] Then _ArrayDisplay($avFilter)
_FFDisConnect()oÝ÷ Ø­#]²×©¥çZÁ¬®²)ම§Á´ e~éܶ*'çºÇ­éâ·lëmx&¢·¥y,¶§ë,që¯#NXýë"EM¦åyjâµäèºÚÈ&®±é²­ë.Û0Y[zj+y§º¶­z'Èv(wg£7ögÚr)àjz-êé®åzdáyªëk'béììj· zÛb    Z®«)ȨÎQ£5Ð*%±h^­çâÖ°k*+櫬ÊÚ zÖ¥Ö­iúè]¢[.׫Ô*%ºÚÈ8¬¦V²h!¶Úþ.8¶)ò¦'¢oörxréø¦+«­éí
^jëh×6#include <FF.au3>
#include <Array.au3>

_FFStart ( "http://www.webpage.com/") 
_FFConnect()


If _FFIsConnected() Then
    
;_FFOpenURL         ("http://www.webpage.com/")

_FFFormOptionselect ("AgeCategoryDropDownList","name", 4, "value")
_FFFormOptionselect ("GenderDropDownList","name", 2, "value")
_FFFormSubmit       ("aspnetForm","name")



$aTable = _FFTableWriteToArray(5)
_ArrayDisplay($aTable)
EndIf

I'm not asking you to write the whole code down. To guide me into the right ways.

Thank you.

Link to comment
Share on other sites

I want all the cols under 1 col

$aArray = _FFXPath("//table[6]//tr/td[2]","textContent",6) ; index from 1-n
_ArrayDisplay($aArray)oÝ÷ Øýz-²êÞûaÌ(®L"¶¨ººZæÞq«¬xhmz0 z+b°@ÈL(®H§ìZ^jëh×6#include <Array.au3>
#include <FF.au3>

_FFConnect()

_FFOpenURL("http://ff-au3-example.thorsten-willert.de/")

$aArray = _FFXPath("//table//tr[4]//table//tr/td[2]","textContent",6,6)
_ArrayDisplay($aArray)
Edited by Stilgar
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...