Champak Posted May 21, 2008 Posted May 21, 2008 I'm trying to combine GuiCtrlReads (ex. 1, 2) so I don't have to check it multiple times (ex. 3 below). Problem is, if I have "Wolf Dog" (ex. 2) in the string, it will be picked up by ex. 1 because of the "Dog". Is there a better way of combining multiple GuiCtrlReads without doing it like ex. 3? If StringInStr("Dog|Cat",GUICtrlRead($ControlRead), 1) Then;ex. 1 GUICtrlSetImage($ControlSet, $Animal5) ElseIf StringInStr("Wolf Dog|Wolf|Fox",GUICtrlRead($ControlRead), 1) Then;ex. 2 GUICtrlSetImage($ControlSet, $Animal6) ElseIf GUICtrlRead($ControlRead) = "Lions" Or GUICtrlRead($ControlRead) = "Tigers" Or GUICtrlRead($ControlRead) = "Bears" Or GUICtrlRead($ControlRead) = "Oh My!" Then;ex. 3 GUICtrlSetImage($ControlSet, $Animal7) EndIf
zackrspv Posted May 21, 2008 Posted May 21, 2008 I'm trying to combine GuiCtrlReads (ex. 1, 2) so I don't have to check it multiple times (ex. 3 below). Problem is, if I have "Wolf Dog" (ex. 2) in the string, it will be picked up by ex. 1 because of the "Dog". Is there a better way of combining multiple GuiCtrlReads without doing it like ex. 3?If StringInStr("Dog|Cat",GUICtrlRead($ControlRead), 1) Then;ex. 1 GUICtrlSetImage($ControlSet, $Animal5) ElseIf StringInStr("Wolf Dog|Wolf|Fox",GUICtrlRead($ControlRead), 1) Then;ex. 2 GUICtrlSetImage($ControlSet, $Animal6) ElseIf GUICtrlRead($ControlRead) = "Lions" Or GUICtrlRead($ControlRead) = "Tigers" Or GUICtrlRead($ControlRead) = "Bears" Or GUICtrlRead($ControlRead) = "Oh My!" Then;ex. 3 GUICtrlSetImage($ControlSet, $Animal7) EndIfI supose you could just write a regular expression to find if the word 'dog' is by itself or if it's part of a word. This way you limit what example 1 and example 2 are capable of. -_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë ë§§ëñ§ë øƒ !ïƒë.
PsaltyDS Posted May 21, 2008 Posted May 21, 2008 I'm trying to combine GuiCtrlReads (ex. 1, 2) so I don't have to check it multiple times (ex. 3 below). Problem is, if I have "Wolf Dog" (ex. 2) in the string, it will be picked up by ex. 1 because of the "Dog". Is there a better way of combining multiple GuiCtrlReads without doing it like ex. 3?If StringInStr("Dog|Cat",GUICtrlRead($ControlRead), 1) Then;ex. 1 GUICtrlSetImage($ControlSet, $Animal5) ElseIf StringInStr("Wolf Dog|Wolf|Fox",GUICtrlRead($ControlRead), 1) Then;ex. 2 GUICtrlSetImage($ControlSet, $Animal6) ElseIf GUICtrlRead($ControlRead) = "Lions" Or GUICtrlRead($ControlRead) = "Tigers" Or GUICtrlRead($ControlRead) = "Bears" Or GUICtrlRead($ControlRead) = "Oh My!" Then;ex. 3 GUICtrlSetImage($ControlSet, $Animal7) EndIfBracket every item with the delimiter, this avoids partial matches: $sString = "|" & StringStripWS(GUICtrlRead($ControlRead), 1 + 2) & "|" If StringInStr("|Dog|Cat|", $sString, 1) Then;ex. 1 GUICtrlSetImage($ControlSet, $Animal5) ElseIf StringInStr("|Wolf Dog|Wolf|Fox|", $sString, 1) Then;ex. 2 GUICtrlSetImage($ControlSet, $Animal6) ElseIf StingInString("|Lions|Tigers|Bears|Oh My!|", $sString) Then;ex. 3 GUICtrlSetImage($ControlSet, $Animal7) EndIfIf the literal "|" might be in your string, use something more rare, like Chr(1), for the delimiter. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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