Jump to content
Sign in to follow this  
=sinister=

Using Arrays To Find Data

Recommended Posts

=sinister=

$Read = GUICtrlRead($Password)
    $GetPasswords = GetPasswords()
    If $Read = $GetPasswords Then
    MsgBox(0, "test", "good")
    Else
;Bad
    EndIf

Func GetPasswords()

    $Pass01 = "lala"
    $Pass02 = "lolo"
    $Pass03 = "fofo"
    $Pass04 = "gogo"
    $Pass05 = "momo"
    
    $GetPass = _ArrayCreate($Pass01, $Pass02, $Pass03, $Pass04, $Pass05)
    
    Return $GetPass

EndFunc

Why doesn't this work? $Password is an input box.

Edited by =sinister=

Share this post


Link to post
Share on other sites
Danny35d

May this if statement work better for you

If StringInStr($GetPasswords, $Read) <> 0 Then


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites
Helge

$Read is a string and $GetPasswords is an array so comparing those wouldn't work.

You have to compare $Read with all the elements in the array..either "manually" or

by using _ArraySearch.

Share this post


Link to post
Share on other sites
=sinister=

Ok, so I got this:

$Read = GUICtrlRead($Password)
    
;<--Passwords
    
        Dim $Pass[6]
    $Pass[0] = "String0"
    $Pass[1] = "String1"
    $Pass[2] = "String2"
    $Pass[3] = "String3"
    $Pass[4] = "String4"
    $Pass[5] = "String5"
    
;<--End Passwords
    
    $Pos = _ArraySearch ($Pass, $Password)
    If $Pos = -1 Then
;Error
Else
    MsgBox(0, "test", "good")
EndIf

Still doesn't work?

Share this post


Link to post
Share on other sites
Danny35d

#include <Array.au3>

$Read = GUICtrlRead($Password)
    $GetPasswords = GetPasswords()
    If _ArraySearch($GetPasswords, $Read) <> -1 Then
        MsgBox(0, "test", "good")
    Else
        MsgBox(0, "test", "bad")
    EndIf

Func GetPasswords()

    $Pass01 = "lala"
    $Pass02 = "lolo"
    $Pass03 = "fofo"
    $Pass04 = "gogo"
    $Pass05 = "momo"
    
    $GetPass = _ArrayCreate($Pass01, $Pass02, $Pass03, $Pass04, $Pass05)
    
    Return $GetPass

EndFunc
This work now, I didn't notice the array on my first post.


AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites
=sinister=

Thanks! It works perfectly!

Share this post


Link to post
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
Sign in to follow this  

×