Kaeft Posted July 15, 2010 Share Posted July 15, 2010 (edited) Well here's something strange. Why does this not work: Func _ArySrchDel($array, $word, $case, $column) $r = 0 While $r = 0 $todelete = _ArraySearch($array, $word, 0, 0, $case, 0, 1, $column) If @error Then $r = 1 Else MsgBox(1,"This is being deleted",$todelete & " Which is " & $word) _ArrayDelete($array, $todelete) If @error Then $r = 1 msgbox(1,"Error","Did not delete " & $word & "." & @error) Else $r = 0 msgbox(1,"Success","Entry " & $word & " deleted.") EndIf Endif WEnd EndFunc _ArySrchDel($aLinks,"Similar",1,5) but this does: While $r = 0 $todelete = _ArraySearch($aLinks, "Similar", 0, 0, 1, 0, 1, 5) If @error Then $r = 1 Else MsgBox(1,"This is being deleted",$todelete & " Which is " & "Similar") _ArrayDelete($aLinks, $todelete) If @error Then $r = 1 msgbox(1,"Error","Did not delete " & "Similar" & ". " & @error) Else $r = 0 msgbox(1,"Success","Entry " & "Similar" & " deleted.") EndIf Endif WEnd Here's all the code I'm tinkering with. Take note of the includes: expandcollapse popup#include <ff.au3> #include <file.au3> #Include <Array.au3> $line = 1 $File = "words.txt" $Numberoflines = _FileCountLines($File) $aLinks = 0 $r = 0 $todelete = 0 Func _ArySrchDel($array, $word, $case, $column) $r = 0 While $r = 0 $todelete = _ArraySearch($array, $word, 0, 0, $case, 0, 1, $column) If @error Then $r = 1 Else MsgBox(1,"This is being deleted",$todelete & " Which is " & $word) _ArrayDelete($array, $todelete) If @error Then $r = 1 msgbox(1,"Error","Did not delete " & $word & "." & @error) Else $r = 0 msgbox(1,"Success","Entry " & $word & " deleted.") EndIf Endif WEnd EndFunc While $line < $Numberoflines $Words = FileOpen($File) $stringread = FileReadLine($Words,$line) FileClose($Words) $line += 1 _FFStart("www.google.com") WinWaitActive("Google - Mozilla Firefox") sleep(1000) ControlSend("Google - Mozilla Firefox","","",$stringread & "{ENTER}") Sleep(3000) $aLinks = _FFLinksGetAll() _ArraySort($aLinks, 1, 0, 0, 5) sleep(250) ;_ArySrchDel($aLinks,"Similar",1,5) ;_ArySrchDel($aLinks,"Cached",1,5) ;_ArySrchDel($aLinks,"mail",1,5) ;_ArySrchDel($aLinks,"Gmail",1,5) ;_ArySrchDel($aLinks,"sign in",1,5) ;_ArySrchDel($aLinks,"similar",1,5) While $r = 0 $todelete = _ArraySearch($aLinks, "Similar", 0, 0, 1, 0, 1, 5) If @error Then $r = 1 Else MsgBox(1,"This is being deleted",$todelete & " Which is " & "Similar") _ArrayDelete($aLinks, $todelete) If @error Then $r = 1 msgbox(1,"Error","Did not delete " & "Similar" & ". " & @error) Else $r = 0 msgbox(1,"Success","Entry " & "Similar" & " deleted.") EndIf Endif WEnd _ArrayDisplay($aLinks) $line +=1 WEnd Now to the more specifics. I am getting all the links from a normal google web search into an array of info. (for example I am searching google for "yahoo") From there I am sorting, then searching the array for all instances of the word "Similar" in column 5 and then deleting them. I wanted to make a function that would allow me to input which words I want to filter out quickly. The first code about holds the function which reports through msgbox that it is deleting the entries just fine. That is not the case as the array still has entries with the word "Similar" in column 5. The second code is basically the same thing as the function just without the function . (all values are input manually) It works just fine. Is it that I am using the same variables in the function is causing problems? I just can't figure this one out! For those who don't have ff.au3 I included it below. Make sure to also get Mozrepl. (quick google can set you up on that one.)words.txtFF.au3 Edited July 15, 2010 by Kaeft Link to comment Share on other sites More sharing options...
Tvern Posted July 15, 2010 Share Posted July 15, 2010 Your function doesn't return anything. Either make the array ByRef in your function definition, or Return it using the return keyword. (didn't test, but I assume that would cause trouble) Link to comment Share on other sites More sharing options...
Kaeft Posted July 15, 2010 Author Share Posted July 15, 2010 Your function doesn't return anything. Either make the array ByRef in your function definition, or Return it using the return keyword.(didn't test, but I assume that would cause trouble)Wow ok that was way too simple. I am still learning (quite a lot as I go along, mostly by reading the help) so I have never heard of ByRef. And now I just read it. I would never have picked up on that. Cool thanks a bunch! 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