Dent

[SOLVED] Help with Array's (creating 1 Array from 2 Arrays)

4 posts in this topic

#1 ·  Posted (edited)

I just can't get my head around what I'm trying to do.

Ok so I read all the links in a webpage into a 1D array, I then make the array unique as there are some duplicates.

I then find all the entries I want from the array and put the number of the row for those entries into another 1D array.

So I now have two arrays; one has unique links, the other has the numbers of the rows for the links I actually want.

Using the second array I would like to amend the first array, or create a third, with just the links I actually want.

Confused? Welcome to my world.

I'll put the relevant section of code below to show where I am up to.

I've left the _ArrayDisplay in the above code which I am using to check the code does what I wanted. So the above code works fine, I'm just stumped on how to extract the links from $aLinks that I want.

$oLinks = _IELinkGetCollection($oIE)
Local $aLinks[1] = ["Link"]
For $oLink in $oLinks
    _ArrayAdd($aLinks, $oLink.href)
Next
;_ArrayDisplay($aLinks)
$aLinks = _ArrayUnique($aLinks)
;_ArrayDisplay($aLinks)
$aLinksToClick = _ArrayFindAll($aLinks, "azref", 0, 0, 0, 3)
;_ArrayDisplay($aLinksToClick)
Local $aSortedLinks[1] = ["Sorted Links"]

For $i = 0 To UBound($aLinksToClick) - 1
    $Blah = _ArrayExtract($aLinks, $aLinksToClick[$i], $aLinksToClick[$i])
    _ArrayAdd($aSortedLinks, $Blah)
Next

 

Edited by Dent
To include solution

Share this post


Link to post
Share on other sites



Name URL or post the copied data from the array!

Share this post


Link to post
Share on other sites
23 minutes ago, AutoBert said:

Name URL or post the copied data from the array!

Original post edited

Share this post


Link to post
Share on other sites

Solved it myself in the end, for some reason I didn't see the _ArrayExtract command earlier. Edited the code to include the solution.

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

  • Similar Content

    • Ahile07
      Old fashion way search array
      By Ahile07
      Hello guys. Again a dummy question for smart people.
      I'm wondering if any of you can help me with an issue. I've got a list of names that i would like to store into an array variable. Example $names = [name1][name2][name3]
      Then i've got an inputbox that asks for your name. I don't know how i can be able to see if the inputbox value is different then the names. I've done already separate if statements if the values are = with the names. But i want to check for error in case the value of the inputbox is different then my list of names.
      Hope it makes sense.
      Thank you
    • TheAutomator
      easy question about arrays
      By TheAutomator
      Hi people,
      It's been a while
      I have been scripting in vbscript for some time but now i'm back using AutoIt for a project:
      Scripting Adobe Illustrator with AutoIt .
      This vb code needs to be converted:
      Set appRef = CreateObject("Illustrator.Application") 'Create a new document and assign it to a variable Set documentRef = appRef.Documents.Add 'Create a new text frame item and assign it to a variable Set sampleText = documentRef.TextFrames.Add 'Set the contents and position of the TextFrame sampleText.Position = Array(200, 200) sampleText.Contents = "Hello World!" The ... = Array(200,200) part is done in one line in vb, is this possible in AutoIt without declaring an array first?
      I know I sound like a newbie but I never had to use arrays this way before..
      what i have:
      $appRef = ObjCreate("Illustrator.Application") ;Create a new document and assign it to a variable $documentRef = $appRef.Documents.Add ;Create a new text frame item and assign it to a variable $sampleText = $documentRef.TextFrames.Add ;Set the contents and position of the TextFrame ReDim $sampleText.Position[2] = [200, 200] <<<--- doesn't work... $sampleText.Contents = "Hello World!"  
    • Rapidnxit
      [solved] send multiple files by email from a file list
      By Rapidnxit
      Hi! I want to send by mail some files with a certain extension (.xml in my case). These files are located in the script folder. First, I thought to use _FileListToArrayRec function to have a list of these files. But than I don't know how to send them all at once. I know that I can attach multiple files in this way: path1;path2;path3; etc.  and so I have tried to make a string of this type with the path of the files (with a for loop) but It doesn't attach any file (only instructions.txt). How could I do? ( what I did is just an idea, if there's something better that would be great) Thanks!
      $aArrayXml = _FileListToArrayRec(@ScriptDir, "*.xml", $FLTAR_FILES) _ArrayDisplay($aArrayXml, "LIST XML") $LenghtArrayXml = UBound($aArrayXml) If ($LenghtArrayXml > 2) Then For $i = 2 To $LenghtArrayXml - 1 $temp = "&@ScriptDir&""\"&$aArrayXml[$i]&";"&"""" $XmlListFile = $XmlListFile & $temp Next EndIf $XmlListFile = StringTrimLeft($XmlListFile, 1) if($LenghtArrayXml = 2)Then $rc =_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&";"&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) Else $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&$XmlListFile&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) EndIf  
    • ruslanas402
      Open webpages by checking boxes
      By ruslanas402
      Hello everyone, don't even know how to ask.  My code is:
      #include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&amp;') $Checkbox1 = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated
    • jonson1986
      Array Comparison with Logical expressions
      By jonson1986
      Hello,
      I'm having list of words and put them into an array ($WordsList) and try to compare results with logical function if in such a condition that if letter extracted through _StringBetween doesn't exist in Array ($WordsList) then it'll show message box like "Pattern Not found" and if patter found in array then it'll skip if comparison and show last message "All Done". 
      But in my condition, the if comparison is not able to process commands upto my expectations and just show last message only.
      Please help me and guide me further how can i make this possible.
      $file = fileopen(@ScriptDir & "\source.txt", 10) $IE = _IECreate( "http://example.com", 0, 0) $source = _IEDocReadHTML($IE) FileWrite($file, $source) Global $File = @scriptdir & "\source.txt" $sText = FileRead($File) $target_source = _StringBetween($sText, "Dateuploaded</strong><span>", "</span></li><li><strong>Seeders") _ArrayDisplay ($target_source) $WordsList = ("2daysago", "1dayago") If $target_source[0] <> $WordsList Then ; Here is the problem for logical comparison MsgBox ( '', '', 'Pattern Not found') EndIf MsgBox ('', '', 'All Done')