| View previous topic :: View next topic |
| Author |
Message |
xinyin
Joined: 15 Apr 2005 Posts: 2
|
Posted: Fri Apr 15, 2005 9:32 am Post subject: IfInString Error? |
|
|
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 |
|
 |
xinyin
Joined: 15 Apr 2005 Posts: 2
|
|
| Back to top |
|
 |
DrSamRaza_1
Joined: 15 Apr 2005 Posts: 8 Location: Pakistan
|
Posted: Sat Apr 16, 2005 12:19 am Post subject: |
|
|
| 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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5130 Location: eth0 ::1
|
Posted: Sat Apr 16, 2005 12:50 am Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Apr 16, 2005 1:05 am Post subject: |
|
|
| 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 |
|
 |
|