Archive: IP control


IP control
Does anybody have handy IP control which allows to input only valid IP thus making unnecessary complicated checking?


It's a pity that nobody answered. Here is my solution which is just silly checking of a string entered in text box:


Var IpToCheck
Var IpSectionsCount ; every IP consists of 4 sections
Function CheckIsIpValid
Pop $IpToCheck ; trimmed ip

StrCpy $IpSectionsCount 0
${Do}
Push "." ; divider char
Push $IpToCheck

Call SplitFirstStrPart
Pop $1 ; first IP number
Pop $IpToCheck ; the rest of IP string

Push $1 ; verify if numeric
Call IsNumeric
Pop $0

${if} $0 == 0
goto invalid_ip
${else}
${if} $1 < 0
goto invalid_ip
${endif}
${if} $1 > 255
goto invalid_ip
${endif}
${endif}
IntOp $IpSectionsCount $IpSectionsCount + 1
${LoopUntil} $IpToCheck == ""

${if} $IpSectionsCount == 4
Push 1 ; OK, valid IP
${else}
goto invalid_ip
${endif}
Return

invalid_ip:
Push 0 ; Invalid IP
FunctionEnd


The code does not verify a lot of things like that first section is not 0 but suits for most of situations.
SplitFirstStrPart -
http://nsis.sourceforge.net/Get_firs...rest_of_string
IsNumeric - http://forums.winamp.com/showthread....ring+is+number

InstallOptionsEX has custom page function for IP addresses. It may work for what you need.

Also, Check IP might be an alternative way to check an IP address.


I've tried CheckIP but it is a bit obscure. It seems that is really checks ip (not just ip number correctness) which is sometimes not needed in an installer.
I will try to see InstallOptionsEx, thanks!


http://forums.winamp.com/showthread....hreadid=252007

Heh, I thought I was the only one looking for this. I haven't found a workable solution yet. For some reason, InstallOptionsEx has some trouble displaying my InstallOptions pages. (And it doesn't help that the project is abandoned :().

Anyway, I know I posted a bit later than you but I figured the screenshot in mine might help.

Joe


Well... I recommend using the function to verify the IP. The control is buggy, just like everything else in the plug-in.