| View previous topic :: View next topic |
| Author |
Message |
rkuechler
Joined: 31 Jan 2005 Posts: 6
|
Posted: Tue Feb 15, 2005 8:48 am Post subject: Comparing a string or what format is an IP address? |
|
|
Hi!
I had some troubles comparing a string containing an IP address:
| Code: | IP_dns1 = 123.11.111.4
If IP_dns1 = 123.11.111.4
{
Goto, end
}
Else
Goto, beginn |
In this case, AHK should go to label end, but it din't. Does AHK have troubles with the "format" of an IP string because the points in it or am i wrong?
Thanks,
Roman |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Tue Feb 15, 2005 8:55 am Post subject: |
|
|
| Code: | IP_dns1 = 123.11.111.4
If IP_dns1 = 123.11.111.4
{
Goto, end
}
Else
Goto, begin
begin:
MsgBox, begin
Exit
end:
MsgBox, end
Exit |
Tested successfully. |
|
| Back to top |
|
 |
rkuechler
Joined: 31 Jan 2005 Posts: 6
|
Posted: Tue Feb 15, 2005 9:06 am Post subject: Strange - you are right |
|
|
Strange - you are right.
Ok, my example script is simplified. I extracted the really IP address (IP_dns1) from a large string. So i suspect the address could contain more, invisible characters.
But this code worked - i did only remove the points, and i wonder why?:
| Code: | ....
StringReplace, IP_dns1_without_points, IP_dns1, .,, all
If IP_dns1_without_points = 123111114
{
Goto, end
}
Else
.... |
I'm confused a bit.
I will test and report again... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10474
|
Posted: Tue Feb 15, 2005 11:01 am Post subject: |
|
|
In case it helps, you can trim the spaces and tabs from beginning and end of a string by assigning a variable to itself:
var = %var% ; During this, AutoTrim should be at its default setting of "on". |
|
| Back to top |
|
 |
ILL.1
Joined: 29 Sep 2004 Posts: 84
|
Posted: Tue Feb 15, 2005 1:01 pm Post subject: |
|
|
You can always use If VAR Contains IP_ADDRESS to save on trimming problems and other such complications. _________________ ===============
----------ILL.1-----------
=============== |
|
| Back to top |
|
 |
|