Jump to content

Search in Array and Copy the Data


Recommended Posts

Hello,

I will try to be as clear as possible :)

I'm using _IETableGetCollection to get a table from IE to an Array.

I would like to know how to search a word in the array and copy the data in the same row.

Please see the uploaded image. In this array, I would like to search for the word "Australian dollar" and copy the data in the column 4 (1.0121) to my clipboard. And I would like to do it for a coupe of country. For each country I only want the data in the column 4.

Thanks you in advance,

Félix

 

Array.jpg

Edited by Duff360
Link to comment
Share on other sites

  • Moderators

@Duff360 what exactly is confusing you? You already have the code to pull the data from IE, per your first post (it would help if you posted your code, rather than asking us to guess). And _ArraySearch has a 2 very simple examples, so what exactly is not working for you?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I'm able to find the expression "Australian dollar", but how can I copy the data from column 4?
It's probably easy, but I really don't know!

Local $sSearch = "Australian dollar"
Local $sColumn = "0"
$sColumn = Int($sColumn)
Local $iIndex = _ArraySearch($aTableData, $sSearch, 0, 0, 0, 1, 1, $sColumn)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "Not Found", '"' & $sSearch & '" was not found on column ' & $sColumn & '.')
Else
    MsgBox($MB_SYSTEMMODAL, "Found", '"' & $sSearch & '" was found in the array at position ' & $iIndex & ' on column ' & $sColumn & '.')
EndIf

 

Link to comment
Share on other sites

small example

#include <Array.au3>

Local $as_Array[2][5] = _
        [['Currency', '2017-01', '2017-02', '2017-03', '2017-04'], _
        ['Australian dollar', '0.9854', '1.0045', '1.0204', '1.0121']]

Local $i_Index = _ArraySearch($as_Array, 'Australian dollar')

If Not @error Then
    MsgBox(0, '', $as_Array[$i_Index][4])
    ClipPut($as_Array[$i_Index][4])
Else
    MsgBox(0,'Not found', 'Search string not found')
EndIf

 

Edited by benners
typo
Link to comment
Share on other sites

Thank you very much!
This is my final script! :)

Local $oTableCollection = _IETableGetCollection($oIE)
For $oAll In $oTableCollection
    $aTableData = _IETableWriteToArray($oAll, True)
_ArrayDisplay($aTableData)
Local $sSearch = "Australian dollar"
Local $iIndex = _ArraySearch($aTableData, $sSearch, 0, 0, 0, 1, 1, 0)
Next
ClipPut($aTableData[$iIndex][4])

 

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...