AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IfInString Error?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
xinyin



Joined: 15 Apr 2005
Posts: 2

PostPosted: Fri Apr 15, 2005 9:32 am    Post subject: IfInString Error? Reply with quote

I have tried the following code with "IfInString" function but failed. In the code, I want to find out if the %Words% is an url.
Code:
IfInString, %Words%, http://
{
    ...
}


But if %Words% is an url, eg., http://www.google.com
The error is: This variable or function name contains an illegal character. The current thread will exit.

Any suggestion? Do you have any good idea to identify the url? Please share with me.
Back to top
View user's profile Send private message
xinyin



Joined: 15 Apr 2005
Posts: 2

PostPosted: Fri Apr 15, 2005 10:18 am    Post subject: Reply with quote

I kown what is wrong w/ my code. I should put
Code:
IfInString, Words, http://


And I found a good example of Url identification
http://www.autohotkey.com/forum/viewtopic.php?t=1224
Back to top
View user's profile Send private message
DrSamRaza_1



Joined: 15 Apr 2005
Posts: 8
Location: Pakistan

PostPosted: Sat Apr 16, 2005 12:19 am    Post subject: Reply with quote

Quote:

But if %Words% is an url, eg., http://www.google.com
The error is: This variable or function name contains an illegal character. The current thread will exit.



I have an script that has to check whether or not copied text is an URL. I use the following code and it works fine

Code:

Loop, Parse, Words, /
IfInString, A_LoopField, http:
 {
   ; Do Something here
 }
Else
 {
   ; Do something else here
 }



Try it and let me know if it worked
_________________
Intelligence helps, but hard work is the key to Success
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Titan



Joined: 11 Aug 2004
Posts: 5130
Location: eth0 ::1

PostPosted: Sat Apr 16, 2005 12:50 am    Post subject: Reply with quote

Tried and tested example:
Code:
links = http`://www.google.com|msn.com|http://www.yahoo.com|www.autohotkey.com
Loop, Parse, links, |
   if A_LoopField contains http://
      MsgBox, %A_LoopField%`nThe above contains the http:// prefix.
   else
      MsgBox, %A_LoopField%`nThe above does NOT contain the http:// prefix.


There seems to be something with "if Var contains MatchList" working where "IfInString" doesn't which I couldn't identify, bug?
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Apr 16, 2005 1:05 am    Post subject: Reply with quote

Titan wrote:
There seems to be something with "if Var contains MatchList" working where "IfInString" doesn't
If you can ever nail it down, please let me know (though I'd be somewhat surprised if there were any bugs in IfInString due to its simplicity and long testing history).
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group