Jump to content

# _ArrayUnique

## Recommended Posts

By some chance i have seen and checked the functions _ArrayUnique wich use _ArrayInsert inside Array.au3.

I did one function some time ago for my needs to do the same but just in 1D, much more faster; its 6 lines long. Tell me if it could be interesting for someone/something and i could share it.

My english shucks, i know it.

##### Share on other sites

Just provide what you did and we can discuss whether it makes sense to update current function.

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

I dont want be ridiculoues or stupid, mine isnt a general purpose function, it just do it in a 1D array.

My english shucks, i know it.

##### Share on other sites

Ok. I have splited in 3, to do it more versatile for share:

```; #FUNCTION# ====================================================================================================================
; Nombre: __ListUniqueElements ; Author: Zalomalo                                                                             1+1
; Dada una cadena de valores separados por comas, devuelve la cadena con valores unicos, eliminando los repetidos.
; -------------------------------------------------------------------------------------------------------------------------------
Func __ListUniqueElements(\$sLista,\$div=',')
If StringIsSpace(\$sLista) Then Return(0)
Local \$aVectorLista=StringSplit(StringStripWS(\$sLista,3),\$div)
If \$aVectorLista[0] < 1 Then Return(0)
\$sLista=''
For \$i=1 To \$aVectorLista[0]
\$aVectorLista[\$i]=StringStripWS(\$aVectorLista[\$i],3)
If StringIsSpace(\$aVectorLista[\$i]) Or StringInStr(\$sLista,\$aVectorLista[\$i],2,1) Then Continueloop
\$sLista=(StringIsSpace(\$sLista))?(\$aVectorLista[\$i]):(\$sLista&','&\$aVectorLista[\$i])
Next
\$aVectorLista=Null
Return(\$sLista)
EndFunc ;==>__ListUniqueElements

; #FUNCTION# ====================================================================================================================
; Nombre: __StringToArrayVars   ; Author: Zalomalo                                                                            1+1
; Funcion comodin que convierte una cadena de nombres separados por comas a un Vector, de procesos por ejemplo.
; Devuelve el Vector, siempre tiene al menos un componente.
; -------------------------------------------------------------------------------------------------------------------------------
Func __StringToArrayVars(\$sNames,\$div=',')
Local \$aVectorNames=StringSplit(StringStripWS(\$sNames,3),\$div)
SetExtended(\$aVectorNames[0])
Return(\$aVectorNames)
EndFunc ;==>__StringToArrayVars

; #FUNCTION# ====================================================================================================================
; Nombre: __ArrayVarsToString   ; Author: Zalomalo                                                                            1+1
; Funcion comodin que convierte un vector 1D de valores a una cadena de nombres separados por comas.
; Creada para pasar el vector de procesos a matar como argumento a otro proceso. Devuelve la cadena.
; -------------------------------------------------------------------------------------------------------------------------------
Func __ArrayVarsToString(ByRef \$aVectorNames,\$div=',')
If Not IsArray(\$aVectorNames) Then Return(\$aVectorNames)
Local \$sTempLista=''
For \$i=1 To \$aVectorNames[0]
\$sTempLista=(StringIsSpace(\$sTempLista))?(\$aVectorNames[\$i]):(\$sTempLista&\$div&\$aVectorNames[\$i])
Next
Return(\$sTempLista)
EndFunc ;==>__ArrayVarsToString```

So you could:

`Local \$avKK=__StringToArrayVars(__ListUniqueElements(__ArrayVarsToString(\$avKK)))`

Or:

`\$ExeToWait=StringSplit(__ListUniqueElements(__ArrayVarsToString(\$ExeToWait)&',kk.exe,shield.img,reporter64.exe'),',')`

By the way, i did a function to get the 8.3 filename, exe's arguments, full path of exe and the exe with arguments, knowing the exe with a relative path and a root path; but i am not very happy with it. I tryed a bit with RegExps but i failed a bit. Could be somewhere related with this subject where i get some happy idea?.

PD: Im obssesed with optimize performance speed and memory size, because that i setup custom dedicated functions.

Edited by zalomalo

My english shucks, i know it.

##### Share on other sites

I'm surprised nobody responded to this. zalomalo - your implementation may be good for strings, but ArrayUnique() needs to also recognize data types. I'm not sure the current function does ATM: I'll have to dig into the code and take a look. Unfortunately your suggestion does not even preserve the data stored in an array.

Edited by czardas
##### Share on other sites

It is not that what I expected according to the post title "_ArrayUnique" but I like the idea to make string with delimiter unique.

Imho, _StringUnique is more applicable.

Made some tests and it seems to work properly.

This might be useful!

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

Yes UEZ, I think it's a good idea.

##### Share on other sites

I missed this. I don't really see the unique quality of this proposal (no pun intended). Maybe someone could provide usage of this and how it will benefit the mass market.

##### Share on other sites

A delimited string unique function might be faster and use less resources than StringSplit() followed by _ArrayUnique() followed by _ArrayToString(). It needs testing.

##### Share on other sites

I think what guinness is asking is why would you need and/or want a string unique function? When would this ever be useful?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Half the posts in this topic are missing.

Edited by czardas
##### Share on other sites

I assume guinness hacked the db to take back his Like vote.

Please don't send me any personal message and ask for support! I will not reply!

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

No one has really answered my question from post #10, as most of the attention was turned to me suggesting the user should post in the Forum, which I never said. I meant I am not going to add this to the UDFs if it has not real benefit to the library.

##### Share on other sites

I meant I am not going to add this to the UDFs if it has not real benefit to the library.

Of course not. It's more an idea for a string function which may have advantages in specific circumstances, providing it can be done optimally without necessarily accessing array functions. I wouldn't consider it important enough to add to any UDF, unless any visible advantages emerge from trying such an idea.

## 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 account

## Sign in

Already have an account? Sign in here.

Sign In Now
• ### Recently Browsing   0 members

No registered users viewing this page.

• ### Similar Content

• Hello everyone,
I'm trying to pass values to elements in a website.
The elements are present within a table, which is again present within a table, which is inside a form.
I tried to read the form, tables, etc., but with no results. It appears to me that the elements, tables, form, etc., were not read at all.
The following is what I tried. Please guide me.
;I tried the following to read the tables into arrays #include <IE.au3> #include <MsgBoxConstants.au3> Local \$oIE = _IECreate() _IENavigate(\$oIE, "---- URL HERE ----") _IELoadWait(\$oIE) \$o_Table = _IETableGetCollection (\$oIE) \$i_NumTables = @extended For \$i = 0 To \$i_NumTables - 1 Step 1 \$o_Table_Temp2 = _IETableGetCollection (\$oIE, \$i) \$a_TableData = _IETableWriteToArray (\$o_Table_Temp2) _ArrayDisplay(\$a_TableData) Next
;I tried the following code to pass value to the field #include <IE.au3> #include <MsgBoxConstants.au3> Local \$oIE = _IECreate() _IENavigate(\$oIE, "---- URL HERE ----", 0) _IELoadWait(\$oIE) Local \$oForm = _IEFormGetObjByName(\$oIE, "default") Local \$oField = _IEFormElementGetObjByName(\$oForm, "tGroup") _IEFormElementSetValue(\$oField, "---- VALUE HERE ----")
The following is the html view of the website and the highlighted field is the one that I want to pass values to. Since this is an official website, I can't share the exact url.

• By BOUNCER
I'm trying to get the output data from https://www.guilded.gg but it uses a web app that generates that output on the fly and this doesn't show up in the page source.
Only in web inspector of each browser does this data show up. How do I read this data in autoit (equivalent to the web inspector)

thank you
• By bscarano
I'm trying to create an (I believe) _ArraySearch that will look at a 2D array
Local \$avArray[6][2] = [ _ ["07/01/16", "SubString0"], _ ["06/15/16", "SubString1"], _ ["07/01/16", "SubString2"], _ ["06/24/16", "SubString3"], _ ["07/01/16, "SubString4"], _ ["06/30/16", "SubString5"]] and return the number of times that a specific date is shown.
i.e.
07/01/16 = 3
06/30/16 = 1
etc.
I'm thinking:
_ArraySearch(\$avArray.\$Value=_Now(),Column0) But I have no idea if I'm even close.
My goal is to create a updateable field that will tell me the number of "calls" I've logged throughout the day.
Any assistance is appreciated.

Brendon

• hi everyOne

how can control Flash elements (Button , Text , ..) or make autologin to website ?

thanks and Sorry For My Basic English
• By Servant
Why this kind of code below, getting the tag name's element of the ID's element: #include <IE.au3> \$oIE = _IECreate("http://www.example.com/", 0, 1, 1) Sleep(5000) \$element = \$oIE.document.getElementById("element_id") \$tags = \$element.getElementsByTagName("IFRAME") For \$tag In \$tags \$msg = \$tag.contentWindow.document.body MsgBox(0, "Message", \$msg.innerHTML) Next And also this code, getting the class name's element of the ID's element: #include <IE.au3> \$oIE = _IECreate("http://www.example.com/", 0, 1, 1) Sleep(5000) \$element = \$oIE.document.getElementById("element_id") \$classes = \$element.getElementsByClassName("class_name") For \$class In \$classes \$msg = \$class MsgBox(0, "Message", \$msg.innerHTML) Next Returns the error 'Variable must be of type "Object".':
Variable must be of type "Object".: MsgBox(0, "Message", \$msg.innerHTML) MsgBox(0, "Message", \$msg^ ERROR Instead of the inner HTML sources of the tag name's elements and the class name's elements?
What is the right way to do those?
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...