nitekram Posted January 6, 2009 Share Posted January 6, 2009 when i try and run this i get an error - i am trying to delete any index that does not have a value - thanks for your help expandcollapse popup#include <array.au3> Global $hand[7] = [413, 213, 113, 115, 116, 117, 114] _Find($hand) Func _Find($aArray, $checkstraight = 1) Local $CountSuitSpades, $aArrayTempSpades[7] For $i = 0 To UBound($aArray) - 1 If StringLeft($aArray[$i], 1) = 1 And $aArray[$i] > 100 Then $CountSuitSpades += 1 $aArrayTempSpades[$i] = $aArray[$i] EndIf Next Select Case $CountSuitSpades >= 5 $Flusher = 1 If $checkstraight Then _ArrayDisplay($aArrayTempSpades) For $i = 0 To UBound($aArrayTempSpades) - 1 ;If $i = 6 Then ExitLoop If $aArrayTempSpades[$i] = '' Then _ArrayDelete($aArrayTempSpades, $i) Next _ArrayDisplay($aArrayTempSpades) Return $aArrayTempSpades Else Return 1;$Flush EndIf EndSelect EndFunc ;==>_Find 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
jaberwacky Posted January 6, 2009 Share Posted January 6, 2009 I just asked the same question! _arrayDelete() Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Valuater Posted January 6, 2009 Share Posted January 6, 2009 (edited) Like This... NVM 8) Edited January 6, 2009 by Valuater Link to comment Share on other sites More sharing options...
Developers Jos Posted January 6, 2009 Developers Share Posted January 6, 2009 Pretty sure this will error out as we discussed earlier today in this thread: http://www.autoitscript.com/forum/index.php?showtopic=87242 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
nitekram Posted January 6, 2009 Author Share Posted January 6, 2009 Pretty sure this will error out as we discussed earlier today in this thread: http://www.autoitscript.com/forum/index.php?showtopic=87242this points back to my thread? is it not possible? 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Developers Jos Posted January 6, 2009 Developers Share Posted January 6, 2009 (edited) this points back to my thread? is it not possible?oops... try this one: http://www.autoitscript.com/forum/index.ph...st&p=625996 Edited January 6, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 6, 2009 Share Posted January 6, 2009 when i try and run this i get an error - i am trying to delete any index that does not have a value - thanks for your help This is my preferred method, because it delete entries that are not null but contain only whitespace: _ArrayDisplay($aArrayTempSpades) For $i = UBound($aArrayTempSpades) - 1 To 0 Step -1 If StringStripWS($aArrayTempSpades[$i], 8) = '' Then _ArrayDelete($aArrayTempSpades, $i) Next _ArrayDisplay($aArrayTempSpades) 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...
nitekram Posted January 6, 2009 Author Share Posted January 6, 2009 This is my preferred method, because it delete entries that are not null but contain only whitespace: _ArrayDisplay($aArrayTempSpades) For $i = UBound($aArrayTempSpades) - 1 To 0 Step -1 If StringStripWS($aArrayTempSpades[$i], 8) = '' Then _ArrayDelete($aArrayTempSpades, $i) Next _ArrayDisplay($aArrayTempSpades) Thanks for everyones help 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
jvanegmond Posted January 6, 2009 Share Posted January 6, 2009 This is my preferred method, because it delete entries that are not null but contain only whitespace: _ArrayDisplay($aArrayTempSpades) For $i = UBound($aArrayTempSpades) - 1 To 0 Step -1 If StringStripWS($aArrayTempSpades[$i], 8) = '' Then _ArrayDelete($aArrayTempSpades, $i) Next _ArrayDisplay($aArrayTempSpades) Psalty, how can you do that. You know better not to change an array while you're iterating on it. github.com/jvanegmond Link to comment Share on other sites More sharing options...
martin Posted January 6, 2009 Share Posted January 6, 2009 Psalty, how can you do that. You know better not to change an array while you're iterating on it.I don't think it's a problem because PsaltyDS made sure he started at Ubound -1 and worked backwards, so the the element deleted is not one of the elements still to be considered. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 7, 2009 Share Posted January 7, 2009 Psalty, how can you do that. You know better not to change an array while you're iterating on it. As Martin pointed out, this is exactly how that's done, by walking the array backwards so your changes don't impact the elements you haven't dealt with yet. The primary reason NOT to do it this way is speed. The function _ArrayDelete() does a lot of ReDim'ing and loops to copy data to new locations. If the performance hit becomes significant, then you can use the "SmOke_N" technique (I don't know if he came up with it, but he did the first example that gave me the 'aha!' moment on it). You assemble a delimited string of all elements to keep and then let StringSplit() or StringRegExp() produce the desired array: _ArrayDisplay($aArrayTempSpades) Local $sTempStr = '' For $i = 0 To UBound($aArrayTempSpades) - 1 If StringStripWS($aArrayTempSpades[$i], 8) <> '' Then $sTempStr &= $aArrayTempSpades[$i] & Chr(1) Next $aArrayTempSpades = StringSplit(StringTrimRight($sTempStr, 1), Chr(1), 2) _ArrayDisplay($aArrayTempSpades) If there are many changes to make this can be much faster. 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...
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