Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-13-2006, 06:10 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
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.
Reply With Quote
  #2  
Old 01-13-2006, 06:54 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 01-13-2006, 09:16 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
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?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:38 PM.


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