Phaser Posted March 12, 2010 Share Posted March 12, 2010 Hi Everyone Long time no post as I found all th eanswers I have needed up to now. I am running an array against data, when the data is found I _ArrayDelete that value from my SET array example At the top of my script I have this Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10] I run the script and it brings back an 8, the $remove = _ArraySearch($0to10array,$thenumber) _ArrayDelete($0to10array, $remove) This all works perfect, all I need to know/do is stop the error at the end when the array has only 2 items left. At the moment I am just using If UBound($0to10array)-1 > 2 Then do the work Else Exit EndIf Is there anyway, instead of just exiting and having to reopen the program, to reload the script so the array is back to how it was on launch? Link to comment Share on other sites More sharing options...
Pain Posted March 12, 2010 Share Posted March 12, 2010 The original array? Since you can't "undo" the operations (ArrayDelete) you have to use a temporary array that you works with. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2010 Moderators Share Posted March 12, 2010 Phaser,I think does what you want: #include <Array.au3> While 1 Global $0to10array[11] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] _ArrayDisplay($0to10array, "Initial") Do $thenumber = Random(0, 10, 1) $remove = _ArraySearch($0to10array,$thenumber) _ArrayDelete($0to10array, $remove) _ArrayDisplay($0to10array, "In loop" ) Until UBound($0to10array) = 1 WEndNote that you need 11 elements for your $0to10array. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phaser Posted March 12, 2010 Author Share Posted March 12, 2010 Hi Pain Yes I want to re-populate the original array example At start Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10] After the work Local $0to10array [10] = [2,8] exit/rerun the whole thing Local $0to10array [10] = [0,1,2,3,4,5,6,7,8,9,10] How do I re-populate it? Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2010 Moderators Share Posted March 12, 2010 Phaser, I just told you. Look up a bit! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Phaser Posted March 12, 2010 Author Share Posted March 12, 2010 Hi Melba23 I posted just before you, glad to see you are still around. Link to comment Share on other sites More sharing options...
Phaser Posted March 12, 2010 Author Share Posted March 12, 2010 Melba23 your script works fine but as always I can't get it working with my setup, it's pointless putting all my code here as it wont run for anyone else, here's what I have Func whatnumbers() $a = $a +1 If $a = 1 Then $b = 0 while $b <= 1 $sum = Eval($0to10array[0] & "x") $sum2 = Eval($0to10array[0] & "y") ControlClick("window name", "", "", "left", 1, $sum, $sum2 ) _ArrayDelete($0to10array, 0) $b = $b +1 WEnd $remove = _ArraySearch($0to10array,$thenumber) _ArrayDelete($0to10array, $remove) ElseIf $a = 2 Then $b = 0 while $b <= 1 $sum = Eval($11to20array[0] & "x") $sum2 = Eval($11to20array[0] & "y") ControlClick("window name", "", "", "left", 1, $sum, $sum2 ) _ArrayDelete($11to20array, 0) $b = $b +1 WEnd $remove = _ArraySearch($11to20array,$thenumber) _ArrayDelete($11to20array, $remove) $a = 0 EndIf EndFunc It basically cycles through each array and (currently) exits when they are empty, as you know I wish to re-populate them both when there's only one left in EITHER of them, any ideas? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 12, 2010 Moderators Share Posted March 12, 2010 Phaser,This code works in theory, but I have not run it as there are a number of points I want to raise first:1. Do you realise the 2 arrays are unequal in size (0To10 is 11 elements, 11To20 is only 10).2. Where does the $thenumber variable come from?3. How are you intending to get out of the function? Is there an end-state or does it run indefinitely (which is what it will do at the moment)? expandcollapse popup#include <Array.au3> whatnumbers() Func whatnumbers() While 1 ; Declare arrays Local $0to10array[11] = [......] Local $11to20array[10] = [......] ; Keep going until one of them has only 1 element left Do $a = $a + 1 If $a = 1 Then $b = 0 While $b <= 1 $sum = Eval($0to10array[0] & "x") $sum2 = Eval($0to10array[0] & "y") ControlClick("window name", "", "", "left", 1, $sum, $sum2) _ArrayDelete($0to10array, 0) $b = $b + 1 WEnd $remove = _ArraySearch($0to10array, $thenumber) _ArrayDelete($0to10array, $remove) ElseIf $a = 2 Then $b = 0 While $b <= 1 $sum = Eval($11to20array[0] & "x") $sum2 = Eval($11to20array[0] & "y") ControlClick("window name", "", "", "left", 1, $sum, $sum2) _ArrayDelete($11to20array, 0) $b = $b + 1 WEnd $remove = _ArraySearch($11to20array, $thenumber) _ArrayDelete($11to20array, $remove) $a = 0 EndIf ; This is where we check if either array has just the one element left Until UBound($0to10array) = 1 Or UBound($11to20array) = 1 ; Now go and reinitialise the arrays WEnd EndFunc ;==>whatnumbersM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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