Pieter Posted April 14, 2006 Share Posted April 14, 2006 (edited) I want to check if the clipboard contains a URL containing an image. This is what I want the script to do: check if the string contains both "http://" and a valid image extension such as .jpg or .bmp. This is the code I used to let the script figure this out:$clipbrdstring = ClipGet() If StringInStr($clipbrdstring, "http://") = 1 And StringInStr($clipbrdstring, ".jpg") = 1 Or StringInStr($clipbrdstring, ".bmp") = 1 Or StringInStr($clipbrdstring, ".gif") = 1 Then GUICtrlSetData( $PhotoDownloadURL, ClipGet()) EndIfI tried it, but it doesn't work the way it should. What's wrong with this piece of code? Is there something wrong with the way I combined the And and Or operators? Edited April 14, 2006 by Pieter iPod + Online calendars = iPodCALsync Link to comment Share on other sites More sharing options...
elgabionline Posted April 14, 2006 Share Posted April 14, 2006 I want to check if the clipboard contains a URL containing an image. This is what I want the script to do: check if the string contains both "http://" and a valid image extension such as .jpg or .bmp. This is the code I used to let the script figure this out:$clipbrdstring = ClipGet() If StringInStr($clipbrdstring, "http://") = 1 And StringInStr($clipbrdstring, ".jpg") = 1 Or StringInStr($clipbrdstring, ".bmp") = 1 Or StringInStr($clipbrdstring, ".gif") = 1 Then GUICtrlSetData( $PhotoDownloadURL, ClipGet()) EndIfI tried it, but it doesn't work the way it should. What's wrong with this piece of code? Is there something wrong with the way I combined the And and Or operators? well, you should read autoit help, in page refered to boolean values. The script could be... $clipbrdstring = ClipGet() Select Case StringInStr($clipbrdstring, "http://") If StringInStr($clipbrdstring, ".jpg") Or StringInStr($clipbrdstring, ".bmp") Or StringInStr($clipbrdstring, ".gif") Then GUICtrlSetData( $PhotoDownloadURL, ClipGet()) EndIf Case Else $clipbrdstring=0;to free memory EndSelect Link to comment Share on other sites More sharing options...
CyberSlug Posted April 14, 2006 Share Posted April 14, 2006 (edited) It's buried, but the docs contain a list of the predecence of operations. Like other languages, AND has higher precedence than OR.Your expression is evaluated as follows:IF (h AND j) OR b OR gInstead you want to add explicit parentheses:IF h AND (j OR b OR g)Hope that helps Edited April 14, 2006 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Pieter Posted April 15, 2006 Author Share Posted April 15, 2006 (edited) It doesn't. Sorry. I triedIf StringInStr($clipbrdstring, "http://") = 1 And (StringInStr($clipbrdstring, ".jpg") = 1 Or StringInStr($clipbrdstring, ".bmp") = 1 Or StringInStr($clipbrdstring, ".gif") = 1) Then GUICtrlSetData( $PhotoDownloadURL, $clipbrdstring) EndIf Edited April 15, 2006 by Pieter iPod + Online calendars = iPodCALsync Link to comment Share on other sites More sharing options...
MHz Posted April 15, 2006 Share Posted April 15, 2006 Try this: ClipPut('http:// .gif') $clipbrdstring = ClipGet() If StringInStr($clipbrdstring, "http://") And _ ( StringInStr($clipbrdstring, ".jpg") Or _ StringInStr($clipbrdstring, ".bmp") Or _ StringInStr($clipbrdstring, ".gif") ) Then MsgBox(0, '', $clipbrdstring) EndIf Link to comment Share on other sites More sharing options...
Pieter Posted April 17, 2006 Author Share Posted April 17, 2006 Yup, that works. iPod + Online calendars = iPodCALsync 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