Jump to content

Autoit Array Matching


Recommended Posts

I'm not sure if this is what you mean. You need this: https://www.autoitscript.com/forum/topic/179779-_arraydeclarefromstring-_arraytodeclarationstring-_arrayshufflemultidim-_arraycompare-_arrayenumvalues-_arrayassign/

#include 'ArrayMultiDim.au3'

Global $array1[3] = ['A','B','C']
Global $array2[3] = ['1','2','3']

If _ArrayToDeclarationString($array1) == _ArrayToDeclarationString($array2) Then ; change == operator to = for case insensitive check
    MsgBox(0, "", "Arrays are identical.")
Else
    MsgBox(0, "", "Arrays are different.")
EndIf

Edit: Hmm it seems you mean something else.

Edited by czardas
Link to comment
Share on other sites

3 hours ago, AutoBert said:

More info's please. Why should 'A' match 3?  What should matching C, and what B?

I wanted to make some array matching. I want to make the $array1 each element correspond with the $array2 each element.So the basic idea is to create a corresponded for $array1 in $array2 , like the images bellow.

image3.png

image2.png

image1.png

Link to comment
Share on other sites

Something like this:

$oDictionary = ObjCreate("Scripting.Dictionary")
$oDictionary.ADD("A", "1")
$oDictionary.ADD("B", "2")
$oDictionary.ADD("C", "3")

Or Like this:

$oDictionary = ObjCreate("Scripting.Dictionary")
$oDictionary.ADD("A", "3")
$oDictionary.ADD("B", "1")
$oDictionary.ADD("C", "2")

Regards
Alien.

Link to comment
Share on other sites

Not sure what the goal is here.  You could use a scripting dictionary like Alien has shown.  You could use another array to pair up the array indexes.  You could even use a 1 dim array with values and a 2 dim array to create pairs.  

Lots of options, but like I said...without knowing the goal it's hard to tailor/polish a solution.

Link to comment
Share on other sites

2 hours ago, AutoBert said:

@alien4u: in a Scripting Dictionary for each key can only exists one value.

@Chimp: seem that TE means your solution, the solution is showing all posible combinations of both arrays

Hi @AutoBert
Of course in my example there is two different illustrative examples this is why I said "Like this" "OR like this", 2 different codes but not the same code twice in the same script.
Sorry If I was not clear enough. 

Regards
Alien.

Edited by alien4u
Typo
Link to comment
Share on other sites

Ich spreche nur wenig.  Ich spielte Fußball vor 15 Jahren.

And did 6-8 grade in Wurzburg, So as long as you are calling me something derogatory, or telling me to sit down on the bench, then I should understand just fine.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

1 hour ago, AutoBert said:

May be talking in native language is better, i am german

I don't understand what you mean but anyways I'm Cuban and the last time I check Spanish is more difficult than German.
But this is an English speaking forum so again I don't get what you mean.

Regards
Alien.

Link to comment
Share on other sites

spanish is much easier for me than german.  compound languages are a biatch inasmuch as they smash words together :)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

We should not probably discuss this here but is not the same in English? Contractions? and words like: meritless, childhood and so on, to many to list?

Anyways I don't get what he try to point.
 

And to be clear I mean no offend to anyone I just don't understand what @AutoBert try to point.

Regards
Alien.

Link to comment
Share on other sites

eh, discussing things and going off topic are what nights are for.  And it was a joke to use inasmuch , which is three words smashed together, to say that is the issue with another language.

They do both have a ton of phoenitically similar sounding words, but thats probably indicative of all the Western Germanic languages.

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Hello. Just for fun.

 

#include <Crypt.au3>


Global $array1[3] = ['A', 'B', 'C']
Global $array2[3] = ['1', '2', '3']

Global $array3[5] = ['A', 'B', 'C', "Autoit", ":)"]
Global $array4[5] = ['3', '1', '2', "Rocks", ":S"]

_CreateMatch($array1, $array2) ;Create Match base in a fingerprint of array data
_CreateMatch($array3, $array4)

ConsoleWrite("Array Match: " & _CheckMatch($array1, $array2) & @CRLF) ;match
ConsoleWrite("Array Match: " & _CheckMatch($array3, $array4) & @CRLF) ;match

;change some array values to change the match
$array1[2] = ":("
$array3[3] = "Danyfirex"

ConsoleWrite("Array Match: " & _CheckMatch($array1, $array2) & @CRLF) ;not match
ConsoleWrite("Array Match: " & _CheckMatch($array3, $array4) & @CRLF) ;not match




Func _CheckMatch($aArray1, $aArray2)
    Local $sString = ""
    Local $sVar = ""
    If Not UBound($aArray1) = UBound($aArray2) Then Return SetError(1, 0, False)
    For $i = 0 To UBound($aArray1) - 1
        $sString &= $aArray1[$i] & $aArray2[$i]
    Next
;~  ConsoleWrite($sString & @CRLF)
    $sVar = "fingerprint" & Hex(_Crypt_HashData($sString, $CALG_MD5))
;~  ConsoleWrite($sVar & @CRLF)
    Return IsDeclared($sVar)
EndFunc   ;==>_CheckMatch

Func _CreateMatch($aArray1, $aArray2)
    Local $sString = ""
    Local $sVar = ""
    If Not UBound($aArray1) = UBound($aArray2) Then Return SetError(1, 0, False)
    For $i = 0 To UBound($aArray1) - 1
        $sString &= $aArray1[$i] & $aArray2[$i]
    Next
;~      ConsoleWrite($sString & @CRLF)
    $sVar = "fingerprint" & Hex(_Crypt_HashData($sString, $CALG_MD5))
;~      ConsoleWrite($sVar & @CRLF)
    If Not IsDeclared($sVar) Then
        Assign($sVar, 0, 2)
        Return SetError(0, 0, True)
    Else
        Return SetError(2, 0, False)
    EndIf
EndFunc   ;==>_CreateMatch

El español es bello lol

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

 

27 minutes ago, iamtheky said:

spanish is much easier for me than german.

59 minutes ago, iamtheky said:

Ich spreche nur wenig.  Ich spielte Fußball vor 15 Jahren.

Then your speaking perfect spanish, but understand the same german slang. Würzburg is < 50 km to my hometown.

@alien4u: it was just for clarify, but meanwhile i know: just 2 examples.

 

Edited by AutoBert
Link to comment
Share on other sites

1 hour ago, AutoBert said:

 

@alien4u: it was just for clarify, but meanwhile i know: just 2 examples.

 

Here you lost me again. What you mean? 2 examples about what? Sorry I feel a little dump right now look like Cuban's beer is not as good as German ones(this is not a joke is a fact.)

Regards
Alien.

Edited by alien4u
Link to comment
Share on other sites

Living in south tx I am better with Spanish slang.  The difference between bavarian and franconian slang was like two different languages. 

Do you want all possibilities, or to be able to set the matches.  Can you make a complete one and have us divide it back into the original two arrays?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...