Page 1 of 1 1
Topic Options
#81204 - 2002-08-28 06:14 PM Split() behavior alteration
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Current: If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.

I think that if a delimiter of zero length is used then the individual characters of the string should become elements of an array.

$a = split("word","")

should yield

"w" = $a[0]
"o" = $a[1]
"r" = $a[2]
"d" = $a[3]

[ 28. August 2002, 18:15: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81205 - 2002-08-28 06:31 PM Re: Split() behavior alteration
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
daa!
that is something. voting for it.

such enchangement would easy up string manipulations...
 
_________________________
!

download KiXnet

Top
#81206 - 2002-08-28 08:18 PM Re: Split() behavior alteration
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
I have to give my vote for this one too.
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#81207 - 2002-09-27 11:36 PM Re: Split() behavior alteration
BrianTX Offline
Korg Regular

Registered: 2002-04-01
Posts: 895
Hmm. this reminds me of that INSTR discussion... about whether an empty string is considered to be in or out of a string or an empty string.

Brian

Top
#81208 - 2002-10-06 11:46 AM Re: Split() behavior alteration
m_a_x_y Offline
Lurker

Registered: 2002-06-24
Posts: 3
This routine should do it:

Break on
Color w/n

Dim $string
Dim $array[0]

$string = "all_people_seem_to_need_data_processing"
$array = splity($string)

For $i=0 to Ubound($array)-1
? $array[$i] + " -> " + $i
Next

Sleep 5

Function splity($s)
Dim $l, $i, $j
Dim $str[0]

$j = 1
$l = Len($s)
ReDim $str[$l]

For $i=0 to $l-1
$str[$i] = Left($s,1)
$s = Right($s,$l-$j)
$j = $j + 1
Next

$splity = $str
EndFunction

[ 06. October 2002, 11:48: Message edited by: m_a_x_y ]

Top
#81209 - 2002-10-06 11:50 AM Re: Split() behavior alteration
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
maxy, yeah... there mostlikely is already a udf for this but it still is too complicated...

for a short inbuild routine the need for 20 lines of script could be avoided...
_________________________
!

download KiXnet

Top
#81210 - 2002-10-06 02:22 PM Re: Split() behavior alteration
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Your signature looks familiar [Smile]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#81211 - 2002-10-06 03:20 PM Re: Split() behavior alteration
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no wonder, the words just happens to be copied from your lines...
_________________________
!

download KiXnet

Top
#81212 - 2002-10-07 10:03 AM Re: Split() behavior alteration
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
You got my vote for it too !
_________________________



Top
#81213 - 2002-10-07 11:20 PM Re: Split() behavior alteration
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Me too!
_________________________
Jack

Top
#81214 - 2002-10-08 01:38 AM Re: Split() behavior alteration
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Makes sense!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#81215 - 2002-11-18 08:15 PM Re: Split() behavior alteration
Andy T Offline
Lurker

Registered: 2002-11-18
Posts: 3
Loc: Guildford, Surrey, England
Yep - I vote for that behaviour too... it does just what it says it does - splits on nulls between each character.
Top
#81216 - 2002-11-18 08:51 PM Re: Split() behavior alteration
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
code:
break on

$s="hello every one"
for each $char in EachChar($s)
? "$char "+asc($char)
next

quit

function EachChar($string)
dim $arrTemp[len($string)-1]
dim $pos
for $pos=1 to len($string)
$arrTemp[$pos-1]=substr($string,$pos,1)
next
$EachChar=$arrTemp
endfunction

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.07 seconds in which 0.032 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