Jump to content

Problem _ArrayUnique _ArraySort Upper and lower case


Recommended Posts

I do not want to separate upper and lower case letters

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $aEditRead
$Form1 = GUICreate("Form1", 581, 352, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 24, 32, 145, 225)
GUICtrlSetData(-1, "Autoit" & @CRLF & "autoit" & @CRLF & "autoitscript"  & @CRLF & "autoitscript" & @CRLF & "123" & @CRLF & "123" & @CRLF & "Autoitscript" & @CRLF & "autoitscript.com" & @CRLF & "autoitscript.coM" & @CRLF & "Autoitscript" & @CRLF & "123a" & @CRLF & "123A" & @CRLF & "AutoitscripT")
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 184, 32, 145, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Delete similar", 24, 296, 70, 33)
$Label2 = GUICtrlCreateLabel("", 208, 272, 46, 17)
$Button2 = GUICtrlCreateButton("Copy", 200, 296, 75, 33)
$Edit3 = GUICtrlCreateEdit("" & @CRLF, 344, 32, 185, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
$Label1 = GUICtrlCreateLabel("Similar ones", 368, 272, 97, 24)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            _deletesimilar()
    EndSwitch
WEnd

Func _deletesimilar()
    $aEditRead = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2)
    $aUniques=_ArrayUnique($aEditRead)

    For $i = 1 To $aUniques[0]
     GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1)
       GUICtrlSetData($Label2, "Deleted")
    Next

    _ArraySort($aEditRead)
             For $i = UBound($aEditRead) - 1 To 1 Step -1
   If $aEditRead[$i] = $aEditRead[$i - 1] Then GUICtrlSetData($Edit3, $aEditRead[$i] & @CRLF, 1)
Next
EndFunc

 

Edited by youtuber
Link to comment
Share on other sites

  • Moderators

I do not know what you mean by separate, running your script didn't give me any more clarity.

If a upper/lower case makes a difference in keeping it versus deleting it, use the case sensitivity in _ArrayUnique (4th Param)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thank you for your answers

I'm getting an error

 

f267abb6244b4ce3a80bbf7077db2498.png

Line 36:  GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1)

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $aEditRead
$Form1 = GUICreate("Form1", 581, 352, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 24, 32, 145, 225)
GUICtrlSetData(-1, "Autoit" & @CRLF & "autoit" & @CRLF & "autoitscript"  & @CRLF & "autoitscript" & @CRLF & "123" & @CRLF & "123" & @CRLF & "Autoitscript" & @CRLF & "autoitscript.com" & @CRLF & "autoitscript.coM" & @CRLF & "Autoitscript" & @CRLF & "123a" & @CRLF & "123A" & @CRLF & "AutoitscripT")
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 184, 32, 145, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Delete similar", 24, 296, 70, 33)
$Label2 = GUICtrlCreateLabel("", 208, 272, 46, 17)
$Button2 = GUICtrlCreateButton("Copy", 200, 296, 75, 33)
$Edit3 = GUICtrlCreateEdit("" & @CRLF, 344, 32, 185, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
$Label1 = GUICtrlCreateLabel("Similar ones", 368, 272, 97, 24)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            _deletesimilar()
    EndSwitch
WEnd

Func _deletesimilar()
    $aEditRead = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2)
    ;~ $aUniques=_ArrayUnique($aEditRead)
    $aUniques = _ArrayUnique($aEditRead, 0, 0, 1, 0)

    For $i = 1 To $aUniques[0]
     GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1)
       GUICtrlSetData($Label2, "Deleted")
    Next

    _ArraySort($aEditRead)
             For $i = UBound($aEditRead) - 1 To 1 Step -1
   If $aEditRead[$i] = $aEditRead[$i - 1] Then GUICtrlSetData($Edit3, $aEditRead[$i] & @CRLF, 1)
Next
EndFunc

 

Link to comment
Share on other sites

Something like this here?

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $aEditRead
$Form1 = GUICreate("Form1", 581, 352, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 24, 32, 145, 225)
GUICtrlSetData(-1, "Autoit" & @CRLF & "autoit" & @CRLF & "autoitscript"  & @CRLF & "autoitscript" & @CRLF & "123" & @CRLF & "123" & @CRLF & "Autoitscript" & @CRLF & "autoitscript.com" & @CRLF & "autoitscript.coM" & @CRLF & "Autoitscript" & @CRLF & "123a" & @CRLF & "123A" & @CRLF & "AutoitscripT")
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 184, 32, 145, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Delete similar", 24, 296, 70, 33)
$Label2 = GUICtrlCreateLabel("", 208, 272, 46, 17)
$Button2 = GUICtrlCreateButton("Copy", 200, 296, 75, 33)
$Edit3 = GUICtrlCreateEdit("" & @CRLF, 344, 32, 185, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
$Label1 = GUICtrlCreateLabel("Similar ones", 368, 272, 97, 24)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            _deletesimilar()
    EndSwitch
WEnd

Func _deletesimilar()
    $aEditRead = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2)
    $aUniques=_ArrayUnique($aEditRead, 0, 0, 1)
    $aUniques2=_ArrayUnique($aEditRead)
    For $i = 1 To UBound($aUniques) - 1
        $aPos = _ArrayFindAll($aEditRead, $aUniques[$i], 0, 0, 1)
        If UBound($aPos) > 1 Then GUICtrlSetData($Edit2, $aUniques[$i] & @CRLF, 1)
    Next
    GUICtrlSetData($Label2, "Deleted")

    Dim $aSimilar[UBound($aEditRead)]
    $c = 0
    For $i = 1 To UBound($aUniques2) - 1
        $aPos = _ArrayFindAll($aEditRead, $aUniques2[$i])
        If UBound($aPos) > 0 Then
            For $j = 0 To UBound($aPos) - 1
                $aSimilar[$c] = $aEditRead[$aPos[$j]]
                $c += 1
            Next
        EndIf
    Next
    ReDim $aSimilar[$c]
    $aUniques3=_ArrayUnique($aSimilar, 0, 0, 1)
    _ArraySort($aUniques3)
    For $i = 1 to UBound($aUniques3) - 1
        GUICtrlSetData($Edit3, $aUniques3[$i] & @CRLF, 1)
    Next
EndFunc

 

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

Selection of finest graphical examples at Codepen.io

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

Link to comment
Share on other sites

When many words are added
It works very slowly
Is there a solution for this?

It also uses a lot of CPU :(

6f43848452be4d5cb5a2c625febbf9d5.png

 

This is my problem can be solving?

 

ProcessSetPriority(@AutoItPid,4)

or

$dll=DLlOpen("ntdll.dll")
While 1
_HighPrecisionSleep(100*2,$dll)
WEnd
Func _HighPrecisionSleep($iMicroSeconds,$hDll=False)
    Local $hStruct, $bLoaded
    If Not $hDll Then
        $hDll=DllOpen("ntdll.dll")
        $bLoaded=True
    EndIf
    $hStruct=DllStructCreate("int64 time;")
    DllStructSetData($hStruct,"time",-1*($iMicroSeconds*10))
    DllCall($hDll,"dword","ZwDelayExecution","int",0,"ptr",DllStructGetPtr($hStruct))
    If $bLoaded Then DllClose($hDll)
EndFunc

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...