Hasher Posted March 5, 2007 Share Posted March 5, 2007 HI Below is a function I am working on , the only probelm with it is that it grabs dupicate information . So I want to store the data for each URl in a array and if its not present in the Array then write it to a text file > basically I suck at writing arrays so I need some pointers of what I am doing wrong and how I can improve myself Dim $avArray[50] $avArray[1] = "http://www.test.com" Func _FormObject($forms) _IEErrorHandlerRegister ("MyErrFunc1") $url = _IEPropertyGet ($oIE, "locationurl") For $form in $forms $frmobjs = _IEFormElementGetCollection ($form) For $frmobj in $frmobjs if $avArray[1] <> $url Then $avArray[1] = $url for $i = 2 to UBound($avArray) step 1 $avArray[$i] = "" Next $i = 2 EndIf $value = $frmobj.type & $frmobj.name & $frmobj.value $Pos = _ArraySearch($avArray,$value,0,0,0,True) Select Case $Pos = -1 _ArrayAdd($avArray,$value) Case Else ;write to file.... EndSelect if $ret = "" then $ret = SetError (1, 0, 0) EndIf Next Next EndFunc The one error I am getting now is clearing the Array E:\Scripts\Logger\logger.au3 (86) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $avArray[$i] = "" ^ ERROR Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
Valuater Posted March 5, 2007 Share Posted March 5, 2007 Maybe... For $i = 2 to (UBound($avArray) -1) step 1 8) Link to comment Share on other sites More sharing options...
improbability_paradox Posted March 5, 2007 Share Posted March 5, 2007 (edited) Clearing the Array$avArray = 0This is assuming that you want to completely remove the array, entries and all.What Valuater is pointing out is that the number returned by Ubound is one number greater than the last vector of the array (since the array starts at vector 0, or $avArray[0]). This is why he changed your code to Ubound($avArray)-1 Edited March 5, 2007 by improbability_paradox Link to comment Share on other sites More sharing options...
Hasher Posted March 5, 2007 Author Share Posted March 5, 2007 (edited) The whole idea of how array in this function is not working, currently this is the array when I diplay ithttp://img409.imageshack.us/img409/6738/untitledrr6.th.jpgAlso Is there a better way to declare the array when I dont know its size , instead of this?Dim $avArray[20]$avArray[1] = "http://www.test.com" Edited March 5, 2007 by Hasher Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
Hasher Posted March 5, 2007 Author Share Posted March 5, 2007 Anyone ? Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of shhh extensions! Link to comment Share on other sites More sharing options...
therks Posted March 6, 2007 Share Posted March 6, 2007 (edited) To my best knowledge, there's no real better way to declare an array when you don't know the size. But I will point you to ReDim. This keyword lets you resize an array variable, while keeping the contents intact. For example: Dim $array[3] $array[0] = 'one' $array[1] = 'two' $array[2] = 'three' MsgBox(0, '', UBound($array) & ', ' & $array[0]) ; Displays "3, one" ReDim $array[2] ; Resize the array to 2 items MsgBox(0, '', UBound($array) & ', ' & $array[0]) ; Displays "2, one" Dim $array[1] ; ReDECLARE the array to 1 item, thus erasing it's contents MsgBox(0, '', UBound($array) & ', ' & $array[0]) ; Displays "1, "oÝ÷ Ø-ëæ¬jëh×6Dim $array[3] $array[0] = 'one' $array[1] = 'two' $array[2] = 'three'oÝ÷ Ø l¢+-êÞj·²ð,¨»ky«, â 7é«À®¶²o_Û Is actually going to give you: [0] => First item [1] => [2] => [3] => [4] => [5] => Second [6] => Third [7] => Fourth Edited March 6, 2007 by Saunders My AutoIt Stuff | My Github 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