Page 1 of 1 1
Topic Options
#74810 - 2003-04-30 06:03 PM This should be pretty simple
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74811 - 2003-04-30 06:24 PM Re: This should be pretty simple
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
How about using JOIN()?
_________________________
There are two types of vessels, submarines and targets.

Top
#74812 - 2003-04-30 07:26 PM Re: This should be pretty simple
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
I must be really close.. [Embarrassed]

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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74813 - 2003-04-30 07:32 PM Re: This should be pretty simple
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I'm still not sure what exactly you want to do [Confused]
code:
; to remove the spaces
$ip=join(split(@IPADDRESS0,' '),'')
; to form an IP address
$ip=split(@IPADDRESS0,'.')
FOR $i = 0 to 3
$ip[$i]=TRIM($ip[$i])
NEXT
$ip=JOIN($ip,'.')

_________________________
There are two types of vessels, submarines and targets.

Top
#74814 - 2003-04-30 08:55 PM Re: This should be pretty simple
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
That is too simple..

$ip=join(split(@IPADDRESS0,' '),'')

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74815 - 2003-04-30 09:13 PM Re: This should be pretty simple
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
What are you trying to do? Some sort of "Reverse KiXGolf"?
_________________________
There are two types of vessels, submarines and targets.

Top
#74816 - 2003-04-30 10:18 PM Re: This should be pretty simple
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74817 - 2003-04-30 11:19 PM Re: This should be pretty simple
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what is trimmed?
you mean loose of white-space chars or loose of numbers or dots?

what is trimming in this case?

[ 30. April 2003, 23:19: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#74818 - 2003-04-30 11:22 PM Re: This should be pretty simple
Kdyer Offline
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
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#74819 - 2003-04-30 11:29 PM Re: This should be pretty simple
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok.
so, there is not better way than jens has shown, hail to jens.

his golf-score is awesome and he is correct.

his method is better than normal string trimming methods kix provides naturally...
_________________________
!

download KiXnet

Top
#74820 - 2003-05-01 12:38 AM Re: This should be pretty simple
Kdyer Offline
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 ]
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 373 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.06 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org