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 / quick text/string question

Author
Message
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 3rd Aug 2010 11:46
is there a quick/easy way to parse a line of text?

say we have, in a text file,

1, Name1, 4, 2.9, 9
2, Name2, 9, 2.4, 9

how would you go about making a function like:

read string 1, current_string$
string_id$ = get_first_textblock(current_string$)
erase_first_textblock(current_string$)
string_name$ = get_first_textblock(current_string$)
erase_first_textblock(current_string$)
... etc

or is there a more simple way?
RedFlames
18
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 3rd Aug 2010 14:16 Edited at: 3rd Aug 2010 14:16
IanM´s matrix1Utils plugin has these functions:
Quote: "
SPLIT STRING Source String, Delimiter String
Word Count = SPLIT COUNT( )
Word String = GET SPLIT WORD$( Word Number )"


Just use "," as a delimiter.

Incase you don't have the plugins:
http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18
qwe
22
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 3rd Aug 2010 16:38
thanks for that

yeah i need to get familiar with those!
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Aug 2010 17:42 Edited at: 6th Aug 2010 18:00
My space invaders 20 line entry had a fair bit of text manipulation using standard DB commands. Just look at the 20 liner compo for the code, you basically need to use the mid$ command. You can count through a string saving the letters to a another string and simply look for spaces to work out when each word is complete. Hope that helps.

http://s6.bitefight.org/c.php?uid=103081

Login to post a reply

Server time is: 2026-07-25 07:37:08
Your offset time is: 2026-07-25 07:37:08