Jump to content
Sign in to follow this  
beestinga

IsinString?

Recommended Posts

beestinga

Hey,

I've got a variable and I need to check if it's one of the values that I need it to be. The problem is, the variable isn't a string variable, and I don't really want to convert it to a string, because it needs to be an integer (unless I can change it back somehow).

What I was trying is

$test = 3
$acceptable = "1 2 3 4 5 6 7 8 9"
Isinstring($test,$acceptable)

but that clearly doesn't work. Is there anything else I can do to see whether my integer is one of a pre-defined list of integers?

Share this post


Link to post
Share on other sites
SmOke_N

Try this:

$test = 3
$acceptable = "1 2 3 4 5 6 7 8 9"
If _IsAcceptable($test, $acceptable) Then MsgBox(0, 'Found', $test & ' is acceptable.')

Func _IsAcceptable($sNumber, $sString)
    If StringInStr($sString, String($sNumber)) Then Return 1
    Return 0
EndFunc


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.

Share this post


Link to post
Share on other sites
Xenobiologist

HI,

what about:

Global $test = 3
Global $acceptable[10] = ['',1, 2, 3, 4, 5, 6, 7, 8, 9]
For $i=1 To UBound($acceptable)-1
    If $acceptable[$i] = $test Then MsgBox(64,"Info", "Match")
Next

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
beestinga

thx for the responses guys.

I'll try this out tonight.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.