Soledad Posted April 3, 2015 Posted April 3, 2015 hello everybody I have array like this : #include <Array.au3> Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"] _ArrayDisplay($aArray_Base, "Base array") how can I remove duplicated items and set the new size of the Array ?? $aArray_Base[5] = ["1","2","3","5","6"] thanks
Developers Jos Posted April 3, 2015 Developers Posted April 3, 2015 (edited) _ArrayUnique() ? Jos Edited April 3, 2015 by Jos Soledad 1 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.
vyperhand Posted April 3, 2015 Posted April 3, 2015 Does this function do what you are after? https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayUnique.htm Soledad 1
Exit Posted April 3, 2015 Posted April 3, 2015 (edited) #include <Array.au3> Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"] _ArrayDisplay($aArray_Base, "Base array") $aArray_Base=_ArrayUnique($aArray_Base,0,0,0,0) _ArraySort($aArray_Base) _ArrayDisplay($aArray_Base, "Final array")Edit: removed item count in _arrayunique() Edited April 3, 2015 by Exit Soledad 1 App: Au3toCmd UDF: _SingleScript()
mikell Posted April 3, 2015 Posted April 3, 2015 Since no one thought of it before I would say : _ArrayUnique Soledad 1
Soledad Posted April 3, 2015 Author Posted April 3, 2015 thanks so much it works but there is a problem the item "5" still duplicated !!
iamtheky Posted April 3, 2015 Posted April 3, 2015 #include <Array.au3> Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"] For $i = ubound($aArray_Base) - 1 to 1 step -1 For $k = $i - 1 to 0 step - 1 If $aArray_Base[$k] = $aArray_Base[$i] Then _ArrayDelete($aArray_Base , $k) $i -= 1 EndIf Next Next _ArrayDisplay($aArray_Base) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Exit Posted April 3, 2015 Posted April 3, 2015 (edited) @soledad:Try the modified version in post #4. There was an error. Itemcount was not removed. Edited April 3, 2015 by Exit Soledad 1 App: Au3toCmd UDF: _SingleScript()
Soledad Posted April 3, 2015 Author Posted April 3, 2015 #include <Array.au3> Local $aArray_Base[8] = ["1","2","3","1","2","2","5","6"] _ArrayDisplay($aArray_Base, "Base array") $aArray_Base=_ArrayUnique($aArray_Base,0,0,0,0) _ArraySort($aArray_Base) _ArrayDisplay($aArray_Base, "Final array") Edit: removed item count in _arrayunique() thanks so much it works well and thanks for all
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