Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / comma delimited string to array

Author
Message
GoldD Dragon27
18
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 30th Mar 2020 22:30
So I have this String > NameData$[0] = "Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega"

Instead of doing DATA "Alpha","Beta",,,,,and so on and then reading it.

I want to read it into an Array of unknown length until it finds and terminator character or word.

If the String is 20 words or 100 words , the array should be DIM by how many words it finds separated by commas.

I see other languages have stuff like Split()...I don't seem to find any of that in the Documentation Index.

Any help would be appreciated.

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 31st Mar 2020 01:02


It's not too difficult... mind there are actually Text Functions specifically for doing this, but I prefer doing things like this myself... gives you a bit more "Control"
sladeiw
14
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 1st Apr 2020 14:38
IanM's Matrix1 plugins give exactly this functionality:

GET SPLIT DELIMITER$
GET SPLIT WORD POS
GET SPLIT WORD$
SPLIT COUNT
SPLIT CSV STRING
SPLIT DELIMITER$
SPLIT STRING
SPLIT WORD POS
SPLIT WORD$


DB also has native commands to do the same but with less features:

FIRST TOKEN$ : Return String=FIRST TOKEN$(source, delim)
NEXT TOKEN$ : Return String=NEXT TOKEN$(delim)
GoldD Dragon27
18
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 5th Apr 2020 06:39 Edited at: 5th Apr 2020 06:50
Thanks guys, this really helped. Thanks Raven that code is cool.
Im still working from the original help files built into the editor and they don't mention any of the native/built in stuff you guys mentioned.

If finally found the commands you guys are talking about....
I have to goto help/commands/? and look at each individual .HTM file to figure out what things I need...loads of fun...

Login to post a reply

Server time is: 2024-04-26 03:23:12
Your offset time is: 2024-04-26 03:23:12