laffo16 Posted April 10, 2009 Share Posted April 10, 2009 (edited) hey guys, i have an array setup like this: Global $getPrices_arr[1][6][1] [x][y][z] x and y containing normal data, and z is sort of like a dimension based on Time. i'm trying to delete any [z] record which is older then 10 secs. ive had a search but havent found anything yet, anyone known where i can find this function? im aware of Psalty "_ArrayDelete4D", but i think this only deletes the row out of all dimensions. also i dont think array2d udf has it. --- edit i havent tested it yet, but have writen somethin like this so far Func _ArrayDelete3D_Entirely(ByRef $ADE_Input, $ADE_Element) $ADE_Input_o = $ADE_Input $ADE_Input[UBound($ADE_Input_o, 1)][UBound($ADE_Input_o, 2)][UBound($ADE_Input_o, 3)-1] $ADE_int = 0 $ADE_i = 0 For $ADE_i = 0 To UBound($ADE_Input_o, 3) If $ADE_Input_o = $ADE_Element Then ContinueLoop EndIf $ADE_int += 1 $ADE_j = 0 For $ADE_j = 0 To UBound($ADE_Input_o, 2) $ADE_k = 0 For $ADE_k = 0 To UBound($ADE_Input_o, 1) $ADE_Input[$ADE_int][$j][$k] = $ADE_Input_o[$i][$j][$k] Next Next Next Return 1 EndFunc Edited April 10, 2009 by laffo16 Link to comment Share on other sites More sharing options...
laffo16 Posted April 10, 2009 Author Share Posted April 10, 2009 what happened to _ArrayDisplayTree() btw? i must have missed this udf, i tried the example and it doesnt seem to work, although i read it was implimented in autoit at some point but doesnt seem to be in the help file? Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 10, 2009 Share Posted April 10, 2009 (edited) hey guys, i have an array setup like this: Global $getPrices_arr[1][6][1] [x][y][z] x and y containing normal data, and z is sort of like a dimension based on Time. i'm trying to delete any [z] record which is older then 10 secs. ive had a search but havent found anything yet, anyone known where i can find this function? im aware of Psalty "_ArrayDelete4D", but i think this only deletes the row out of all dimensions. also i dont think array2d udf has it. This is what makes array UDFs hard to generalize. The desired actions tend to be very situational and specific to the one-off task at hand. When you delete an element in an array, you delete the ELEMENTS, changing the size of the array in that dimension. This is not same thing as deleting VALUES that meet certain criteria. So in your case, the third index represents some stored timestamps. If you actually ReDim the third dimension, you will change the number of elements for every set of 1st and 2nd dimension, not just one particular coordinate. Assuming the number of conforming time stamps is variable for all the X/Y combinations, to accomplish what you describe without loss of data will require examining all the X/Y combinations and getting a count of conforming timestamps. Then you can move the timestamps to be kept up to the [x][y][0] thur [x][y][n] elements before deleting the higher order third dimension elements. Complicated and painful to code without scrambling data. Perhaps you don't really want to _ArrayDelete() but just null the out-of-date timestamps? Then you don't have to change the size of the array, just code your use of the array to ignore null (or -1, or whatever) values. Then you might remove old timestamps just with: #include <Date.au3> Global $avArray[10][10][10] ; Assumes 3rd index stores timestamps as from TimerInit(), unused values = 0 ; Zero-out timestamps older than 10sec For $x = 0 To UBound($avArray) - 1 For $y = 0 To UBound($avArray, 2) - 1 For $z = 0 To UBound($avArray, 3) - 1 If ($avArray[$x][$y][$z] > 0) And _ (TimerDiff($avArray[$x][$y][$z]) >= 10000) Then $avArray[$x][$y][$z] = 0 EndIf Next Next Next You could add some data movement to keep all the valid timestamps together starting at [x][y][0] and all the invalid ones after those. Edited April 10, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
laffo16 Posted April 10, 2009 Author Share Posted April 10, 2009 thanks for your help psalty, as always very enlightening. it is differcult to explain my situation and i have thought about using a just 2 dimensions as this would make things easier but it just seemed more apporpiate to use the 3rd dimension as time is involved. i will try and post a working example of what i have in a bit. Link to comment Share on other sites More sharing options...
laffo16 Posted April 10, 2009 Author Share Posted April 10, 2009 sry its not a working example, but this is how i went about it in the end expandcollapse popupGlobal $getPrices_arr[1][6][1] ; feed comes from .getPrice obj $getPrices = $BAcom.getPrices() ; prices array (new entry) $UB_3rd = UBound($getPrices_arr, 3) ReDim $getPrices_arr[UBound($getPrices)+1][6][$UB_3rd +1] $int = 0 For $Element In $getPrices $int += 1 $getPrices_arr[0][1][$UB_3rd] = _Timer_Init() $getPrices_arr[$int][1][$UB_3rd] = $Element.Selection $getPrices_arr[$int][2][$UB_3rd] = $Element.backOdds1 $getPrices_arr[$int][3][$UB_3rd] = $Element.layOdds1 $getPrices_arr[$int][4][$UB_3rd] = $Element.lastMatched $getPrices_arr[$int][5][$UB_3rd] = $Element.totalMatched Next ; delete entrys over 10 secs $i = 0 While 1 $i += 1 If $i >= $UB_3rd Then ExitLoop EndIf $timer_check = _Timer_Diff($getPrices_arr[0][1][$i]) If $timer_check >= 10000 Then _ArrayDelete3D_Entirely($getPrices_arr, 1) $i += -1 $UB_3rd += -1 Else ExitLoop EndIf WEnd Func _ArrayDelete3D_Entirely(ByRef $ADE_Input, $ADE_Element) $ADE_Input_o = $ADE_Input Dim $ADE_Input[UBound($ADE_Input_o, 1)][UBound($ADE_Input_o, 2)][UBound($ADE_Input_o, 3)-1] $ADE_int = -1 $ADE_i = 0 For $ADE_i = 0 To UBound($ADE_Input_o, 3) -1 If $ADE_i = $ADE_Element Then ContinueLoop EndIf $ADE_int += 1 $ADE_j = 0 For $ADE_j = 0 To UBound($ADE_Input_o, 2) -1 $ADE_k = 0 For $ADE_k = 0 To UBound($ADE_Input_o, 1) -1 $ADE_Input[$ADE_k][$ADE_j][$ADE_int] = $ADE_Input_o[$ADE_k][$ADE_j][$ADE_i] Next Next Next Return 1 EndFunc 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