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.

AppGameKit Classic Chat / String parse function

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Oct 2013 22:22 Edited at: 22nd Oct 2013 23:21
Returns data from a comma delimited string such as:

2,1,"Buy medicine before","you go",2,4,40,1,0,5,68,0,0,0,1,0

Just specify which chunk(pos) you want. For instance, getChunk$(4,text$) would return "you go", including the quotes. Commas inside quotes are ignored, so you get the entire string you expect. Useful for reading in human-readable file formats like game save data.



Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 22nd Oct 2013 22:27 Edited at: 22nd Oct 2013 22:32
You've not seen the GetStringToken() command, have you my good man?

GetStringToken(text$,",",4) would do the same thing.

Edit: Ahh, noticed you ignore commas inside quotes. Hmmm. That could make it more useful! Cool stuff. Definitely see a use for this logic.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Oct 2013 22:54
I thought there was a tokenizer but I couldn't find the commands.

Fallout
22
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 22nd Oct 2013 23:06
To be fair though, getstringtoken() would split an entry in quotes if the delimiter was inside the quotes, so yours does provide something different.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Oct 2013 23:22
Made a correction to the code to where it wasn't grabbing the full string if a comma was in the quotes. (the key point of this!) It's fixed now.

=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 22nd Oct 2013 23:23
I wrote a selection of CSV commands (Based loosely around the command set in IanM's matrix utilities plugin set for DBP) when I first started converting my DBP Game Template to AGK.

I noticed (and have used in smaller projects) the GetStringToken() command, but have yet to implement it into the template.

I like the way your snippet ignores stuff inside quotes, that's a nice touch

Login to post a reply

Server time is: 2024-11-24 22:46:56
Your offset time is: 2024-11-24 22:46:56