Page 1 of 2
[Implemented] Unlimited Separator$ length @ StringField()
Posted: Wed Dec 06, 2006 4:36 pm
by AND51
Hello!
My favourite command
StringField() can only work correctly, if Separator$ has only 1 character.
Can this be extended? It'd be nice, if Separator$ can have any length!
Concerning this topic, you might have a look at the german forum-thread:
http://www.purebasic.fr/german/viewtopi ... D51#127649
Posted: Wed Dec 06, 2006 4:40 pm
by remi_meier
Or a debugger check to help people avoid this problem. One could also
change the type of the separator to CHARACTER.
But I agree, it would be VERY useful to allow any length of string as
Separator$.
Posted: Wed Dec 06, 2006 6:16 pm
by Fluid Byte
Agreed!
I want this really bad!

Posted: Wed Dec 06, 2006 7:04 pm
by Konne
But it would me much slower.
Posted: Wed Dec 06, 2006 7:53 pm
by Dummy
Konne wrote:But it would me much slower.
only if it's badly coded or you use seperator "ae" on a verly long string filled with 50% "a"s
Posted: Wed Dec 06, 2006 10:30 pm
by AND51
Konne wrote:But it would me much slower.
That's not the matter.
If the PB Team has no other idea, the PB team will use one big If/Else, checking if Separator$'s length is =1 or >1. So, the perfomance doesn not decrease.
@ PB Team: What do you think about my idea? As you can see, there are many other ppl who aagree with me.

Posted: Wed Dec 06, 2006 11:25 pm
by Trond
Fluid Byte wrote:Agreed!
I want this really bad!

I want it good, if you don't mind?

Posted: Thu Dec 07, 2006 2:57 am
by mskuma
I agree this would be useful.. here's hoping for it to appear in the future.. also agree 2 versions of the function should be provided (or internally detected) if the >1 char version is known to be slower than the 1 char version.
Posted: Thu Dec 07, 2006 9:08 am
by Kiffi
Agreed too!
Greetings ... Kiffi
Posted: Thu Dec 07, 2006 11:47 pm
by akj
So we're all agreed then. It's a must-have feature for PureBasic 13.0
Posted: Fri Dec 08, 2006 12:04 am
by AND51
Not PB 13.0

but next PB version or PB update.
Posted: Fri Dec 08, 2006 3:27 am
by JCV
yup its a nice addition.

Posted: Fri Dec 08, 2006 10:52 am
by Konne
Didn't we talk about this and Fred said that it is a stupid idea?.
I don't know.
Re: Unlimited Separator$ length @ StringField()
Posted: Fri Dec 08, 2006 12:17 pm
by PB
I'd just do it like this, with a non-standard text character such as Chr(1) as a placeholder.
So, use StringField for 1 character delimiters, and StringFieldBig for >1 character delimiters.
Code: Select all
Procedure.s StringFieldBig(string$,index,delimiter$)
string$=ReplaceString(string$,delimiter$,Chr(1))
ProcedureReturn StringField(string$,index,Chr(1))
EndProcedure
For k=1 To 6
Debug StringFieldBig("Hello---I---am---a---split---string", k, "---")
Next
Posted: Fri Dec 08, 2006 1:42 pm
by AND51
Smaller, faster, better. Morever, you forgot to protect the variable, that's bad (think of EnableExplicit).
Code: Select all
Macro StringFieldBig(string,index,delimiter)
StringField(ReplaceString(string,delimiter,Chr(1)) ,index,Chr(1))
EndMacro
For k=1 To 6
Debug StringFieldBig("Hello---I---am---a---split---string", k, "---")
Next
I know, how to code a better Stringfield; but this iis not the point. I would like too see an improved StringField in the next Version natively!