Jump to content

Old fashion way search array


Ahile07
 Share

Recommended Posts

Hello guys. Again a dummy question for smart people.

I'm wondering if any of you can help me with an issue. I've got a list of names that i would like to store into an array variable. Example $names = [name1][name2][name3]

Then i've got an inputbox that asks for your name. I don't know how i can be able to see if the inputbox value is different then the names. I've done already separate if statements if the values are = with the names. But i want to check for error in case the value of the inputbox is different then my list of names.

Hope it makes sense.

Thank you

Link to comment
Share on other sites

#include <Array.au3>

Local $names[3] = ["name 1", "name 2", "name 3"]

$sValue = InputBox("", "")

If _ArraySearch($names, $sValue) Then
    MsgBox(0, "", "Wrong Name ! ")
Else
    MsgBox(0, "", "$sValue = " & $sValue)
EndIf

 

Never mind, this didn't work as expected...

Edited by l3ill
Link to comment
Share on other sites

here we go...this one works:

#include <Array.au3>

Local $names[3] = ["name 1", "name 2", "name 3"]

$sValue = InputBox("", "")

If _ArraySearch($names, $sValue) = -1 Then
    MsgBox(0, "", "Wrong Name ! ")
Else
    MsgBox(0, "", "$sValue = " & $sValue)
EndIf

 

Link to comment
Share on other sites

  • Moderators

@Ahile07 did you not notice this at the top of the forum you posted this topic in?

Quote

Do not create AutoIt-related topics here, use the AutoIt General Help and Support

Topic moved; please pay attention to where you post in the future.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

×
×
  • Create New...