#74810 - 2003-04-30 06:03 PM
This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Looking at the FAQ for IP Address Trimming we can do the simple code of -
code:
$1st=LTRIM(SUBSTR(@ipaddress0,1,3));#ip# $2nd=LTRIM(SUBSTR(@ipaddress0,5,3));#ip# Get the IP# and assign it to $ipadr $3rd=LTRIM(SUBSTR(@ipaddress0,9,3));#ip# $4th=LTRIM(SUBSTR(@ipaddress0,13,3));#ip# $ipadr='$1ST.$2ND.$3RD.$4TH';#ip#
Or, taking this to the next level - code:
$1st=LTRIM(split(@ipaddress0,'.')[0]) $2nd=LTRIM(split(@ipaddress0,'.')[1]) $3rd=LTRIM(split(@ipaddress0,'.')[2]) $4th=LTRIM(split(@ipaddress0,'.')[3]) $ipadr='$1ST.$2ND.$3RD.$4TH' ; #ip#
But, wait there's more.. code:
DIM $i FOR $i = 0 to 3 $ip=LTRIM(split(@ipaddress0,'.')[$i]) FOR EACH $i to UBOUND($i) $ip+'.' ENDIF NEXT
The above does not work..
If we remove - code:
DIM $i FOR $i = 0 to 3 $ip=LTRIM(split(@ipaddress0,'.')[$i]) $ip+'.' NEXT
It leaves a trailing ".".
Thanks,
Kent
|
|
Top
|
|
|
|
#74812 - 2003-04-30 07:26 PM
Re: This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I must be really close..
code:
CLS BREAK ON DIM $i,$ip[3] FOR $i = 0 to 3 $ip=LTRIM(split(@ipaddress0,'.')[$i]) $ip=JOIN($ip,'.',$i) ;$ip=$ip+'.' $ip NEXT ;$ip=JOIN(LTRIM(split(@ipaddress0,'.'),'.') get $
Thanks,
Kent
|
|
Top
|
|
|
|
#74814 - 2003-04-30 08:55 PM
Re: This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
That is too simple..
$ip=join(split(@IPADDRESS0,' '),'')
Kent
|
|
Top
|
|
|
|
#74816 - 2003-04-30 10:18 PM
Re: This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
No.. Just trying to get the best way to get the IP Address trimmed down.
Kent
|
|
Top
|
|
|
|
#74818 - 2003-04-30 11:22 PM
Re: This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Lonk,
As you are aware..
@IPADDRESSx
Shows:
__1.__2.__3.__4
With the code we have talked about, this trims down the spaces to be:
1.2.3.4
HTH,
Kent
|
|
Top
|
|
|
|
#74820 - 2003-05-01 12:38 AM
Re: This should be pretty simple
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Updated IP Address trimming
Thanks,
Kent [ 01. May 2003, 00:38: Message edited by: kdyer ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 988 anonymous users online.
|
|
|