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 

Comparing a string or what format is an IP address?

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



Joined: 31 Jan 2005
Posts: 6

PostPosted: Tue Feb 15, 2005 8:48 am    Post subject: Comparing a string or what format is an IP address? Reply with quote

Question
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
View user's profile Send private message
BoBo
Guest





PostPosted: Tue Feb 15, 2005 8:55 am    Post subject: Reply with quote

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

PostPosted: Tue Feb 15, 2005 9:06 am    Post subject: Strange - you are right Reply with quote

Embarassed
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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10474

PostPosted: Tue Feb 15, 2005 11:01 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
ILL.1



Joined: 29 Sep 2004
Posts: 84

PostPosted: Tue Feb 15, 2005 1:01 pm    Post subject: Reply with quote

You can always use If VAR Contains IP_ADDRESS to save on trimming problems and other such complications.
_________________
===============
----------ILL.1-----------
===============
Back to top
View user's profile Send private message
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