Page 1 of 1 1
Topic Options
#150142 - 2005-10-17 11:19 PM [edit] SPLIT [/edit] enhancement
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Split($string,"") or even SPLIT($string) should return an array of single characters. This was suggested previously and rejected. Can it be reconsidered?

Edited by Howard Bullock (2005-10-18 05:33 AM)
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#150143 - 2005-10-17 11:38 PM Re: SPILT enhancement
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I give this a huge big thumbs-up second as well Howard.
Top
#150144 - 2005-10-18 12:08 AM Re: SPILT enhancement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I don't wanna mess with SPLIT or even the suggested SPILT.

I think better (cleaner) is to have a separate function for this.
say, Explode()

why cleaner? because the current behaviour is:
a) already there, been there for quite a while and some scripts rely on it
b) would bring inconsistency. couldn't no more just split with stuff but would need to check for the splitter string to avoid data corruption

not so good explanations but... I like the idea of the new feature but don't wanna see it in split.
_________________________
!

download KiXnet

Top
#150145 - 2005-10-18 12:11 AM Re: SPILT enhancement
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Howard

This one is impossible: SPLIT($string)
Because default split character is allready space, so it cannot be used because of backwords compatibility

This one Split($string,"")
Might be the solution, if Ruud wil make the change

It could be a great tool to find the first different char when comparing two strings

I see that Shawn wishes for this functionality too,
I suspect You both for for this wish to make an easy translates from other programming languages

I'll allso vote for this even if an UDF to split a string into an array of chars only needs about 5 lines.

-Erik

Top
#150146 - 2005-10-18 12:15 AM Re: SPILT enhancement
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Something like?

$array = Chars(string)
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#150147 - 2005-10-18 12:21 AM Re: SPILT enhancement
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Erik (et al) is right - this prolly would cause issues - was reading the docs on the delim param:

Delimiter

Optional. String character(s) used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.

Wonder what that rational was behind that last design choice (to return the entire string instead of an array of chars) ... prolly a useful purpose in that too.

Top
#150148 - 2005-10-18 04:17 AM Re: SPILT enhancement
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Very quick way to turn a sring into an array as part of other functions. Though, the same could already be achieved via REDIM PRESERVE just not embedded in other functions.
Code:

$a='aaa'
$a=split($a)

$b='bbb'
redim preserve $b[0]

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

Top
#150149 - 2005-10-19 12:34 AM Re: SPILT enhancement
kholm Offline
Korg Regular
*****

Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
Shawn

I have to wonder like You:

Quote:

Optional. String character(s) used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.

Wonder what that rational was behind that last design choice (to return the entire string instead of an array of chars) ... prolly a useful purpose in that too.





Why send a string to a function and return the same string??

I belive this is easy to implement for Ruud, that's why i'm woting for it.

It could be done in two ways:

    - Split($string,"") ; Second parameter is an empty string 0-length
    - Split($string,0) ; Second parameter mening no split char


In my oppinion we should not invent a new function to do this!

-Erik

ps.
KiXtart functions behaves exactly like vb-functions, just a litle better (smaller code), why not stay ahead

I hope the suggestion is not spilt

Top
#150150 - 2005-10-19 06:36 AM Re: SPILT enhancement
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Quote:

Why send a string to a function and return the same string??




well, the return value is NOT the same string.
it's an array.

and, I know it would be nice to have this feature but hey, lets not break the current behaviour and scripts just because we don't want to learn new keyword.

also, having:
split(string, number)
won't work as kixtart uses type magic.
that is, kix automatically translates types, so when it should think 0 is intended to be a delimiter and when an option?

again.
I'm not against the functionality but don't wanna be blinded by new tech and trash the backwards compatibility.
_________________________
!

download KiXnet

Top
#150151 - 2005-10-19 02:51 PM Re: SPILT enhancement
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
I agree, i don't want to break the current functionality. Not to mention there are times that i'd like to split a string and get a one-element array out of it - it can be very useful when you don't know what your input looks like.

But another function like Chars() would be nice.

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
2 registered (morganw, mole) and 414 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.058 seconds in which 0.023 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