The IP Address Problem
; ScriptName: IPadresse.kix
; Creator: Brian Petersen
; Date: 24.04.2000
; Description: Tweak for 1 and 2 digits IP-addresses.
; An IP-address is a 32 bit address, written as 4 octets seperated by dots (dot notation).
; 169.254.88.1 and 169.054.088.001 are the same address.
; If an IP address contains 1 og 2 digit numbers, they have to be written that way or
; patched up with 0 or 00. An IP address cannot contain blanks.
; The problem with the KiXtart Macro @IPADDRESS is that it returns the IP address
; as a string containing four octest of 3 characters seperated by dots.
; IP addresses containing 1 and 2 digits are patched with blanks, so...
; Now we have to trim the IP address for blans.
; We will use LTRIM to trim blanks from position x and 3 characters forward...
; First octet (169)...
$IP1 = LTRIM(SUBSTR(@IPADDRESS0, 1, 3))
; Second octet (54)...
$IP2 = LTRIM(SUBSTR(@IPADDRESS0, 5, 3))
; Third octet (88)...
$IP3 = LTRIM(SUBSTR(@IPADDRESS0, 9, 3))
; Fourth octet (1)...
$IP4 = LTRIM(SUBSTR(@IPADDRESS0, 13, 3))
; Show the 4 octets...
; The trimmed IP address is rebuild of the four octets, again seperated by dots...
$MyIP=$IP1 + "." + $IP2 + "." + $IP3 + "." + $IP4
? "Trimmed IP Address: " $MyIP
; Now we have a valid IP address for operations like ping...
; Note that $MyIP is placed within the "" as the value is sent to Shell...
shell "ping $MyIP"