AutoHotkey Community

It is currently May 26th, 2012, 8:09 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: IfInString Error?
PostPosted: April 15th, 2005, 9:32 am 
Offline

Joined: April 15th, 2005, 9:21 am
Posts: 2
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 15th, 2005, 10:18 am 
Offline

Joined: April 15th, 2005, 9:21 am
Posts: 2
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 12:19 am 
Offline

Joined: April 15th, 2005, 11:36 pm
Posts: 7
Location: Pakistan
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 12:50 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 16th, 2005, 1:05 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, poserpro, sjc1000, Tilter_of_Windmills and 52 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group