Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Tokenize option to return delims (https://forums.graalonline.com/forums/showthread.php?t=63394)

jake13jake 01-13-2006 06:10 AM

Tokenize option to return delims
 
I've definitely touched on this in a lot of other threads, but the tokenize function should have the ability to return specified delimiters.
There are several functions that it can serve.
Let's say you have a staff chat command.
Let's say you wanted to be able to have the staff do multiple commands in one event call?
ASSUMING:
this.commandtoken = "/"; //(would be returned by tokenize())
player.chat == "/heal/heal jake13jake";


player.chat.tokenize("/");
//let's assume the "/" was returned as a delim.
for (i=0;i<tokens.size();i+=2) {
if (tokens[i] == "/") {
parsecommands(tokens[i+1]);
}
}
pos() only finds the first one
starts() only finds the first one
unless you want to cycle through and find all of the places it says /, it really defeats the purpose of tokenize.

The amount of functionality this would add is only limited to the extent of the scripter's imagination.

ApothiX 01-13-2006 06:54 AM

Why exactly would you want to do multiple slash-commands on the same line? o_o It seems to me if you were going to do that, you should write your own parser instead of relying on tokenize. Either that or use spaces as your delimiter, and just do if(tokens[i].starts("/"))

I really don't see the benefit of returning the delimiters into separate tokens of their own, I believe it's just a waste of effort and would get annoying as hell to work around. If this ever is implemented it should be strictly an option, or a separate function alltogether.

jake13jake 01-13-2006 09:16 AM

Quote:

Originally Posted by ApothiX
If this ever is implemented it should be strictly an option, or a separate function alltogether.

No kidding!! that's why I say the best way to currently do it would probably be
obj.tokenize(delims,returneddelims);
(overloaded of course)

although, if making it similar to Java it would return all delims.
tokenize(delims,true);

I think making a "which delims are returned" string would probably be more functional. Most programming languages have this functionality, why shouldn't gscript?


All times are GMT +2. The time now is 04:32 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.