beestinga Posted June 15, 2006 Share Posted June 15, 2006 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? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 15, 2006 Moderators Share Posted June 15, 2006 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. Link to comment Share on other sites More sharing options...
Xenobiologist Posted June 15, 2006 Share Posted June 15, 2006 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 Link to comment Share on other sites More sharing options...
beestinga Posted June 15, 2006 Author Share Posted June 15, 2006 thx for the responses guys. I'll try this out tonight. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now