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.

Code Snippets / String tokenizer

Author
Message
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 17th Nov 2006 22:19
This just splits a string up into pieces. It gets split every time it comes across the character that you choose to split it with.

Here's the code:



It would be usefull for things like changing dates from 17/11/2006 into seperate things. Also for things such as reading data from a file, for instance:
cube 1,100,500,300
could easily be split up into componenets like object number and position x/y/z.

Very useful me thinks.

Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 18th Nov 2006 01:49
Cool. It may be faster to use the hidden commands though:

first token$()
next token$()

Have a search for them on the forums.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 18th Nov 2006 02:49
I think I saw one like that that Phaelax made. I didn't like the look of all the Globals, so I tend to like this method more.

Vampiric
18
Years of Service
User Offline
Joined: 30th Oct 2006
Location:
Posted: 20th Nov 2006 18:23
this just what i wanted

All bow down to evil
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2006 18:47
I had to use globals cause there was no way to return an array. The only problem I would have using yours (which appears much smaller in code!) is that it reloops through the string whenever you grab another token.

Login to post a reply

Server time is: 2024-11-22 23:02:37
Your offset time is: 2024-11-22 23:02:37