Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   tokenize help (https://forums.graalonline.com/forums/showthread.php?t=9433)

Xaviar 08-12-2001 11:19 PM

tokenize help
 
will tokenize2 +,blah+blah blah return
#t(0) - blah
#t(1) - blah blah

or will it return

#t(0) - blah
#t(1) - blah
#t(2) - blah

and if it returns the latter...how do I get it to return the former? especially if I dont know how many words will be in my string?

ownerofbabylon 08-12-2001 11:33 PM

what is tokenize used for?

Xaviar 08-12-2001 11:37 PM

Quote:

Originally posted by ownerofbabylon
what is tokenize used for?
tokenize breaks a string into sections based on words and commas...tokenize2 breaks a string into sections based on "delimiters" which you specify before the string....Im just not sure if it uses spaces and commas too =/

LiquidIce00 08-13-2001 12:05 AM

Quote:

Originally posted by Xaviar


tokenize breaks a string into sections based on words and commas...tokenize2 breaks a string into sections based on "delimiters" which you specify before the string....Im just not sure if it uses spaces and commas too =/

delims are used as the space. the delim for the normal tokinizing is space. so if you change it like you said it would return what u said o.o
and if you dont know how long ur string is then you can just do tokenscount which returns the number of tokens.

Xaviar 08-13-2001 01:51 AM

nope dude..I tried...tokenize2 +,blah blah blah; returns
#t(0) - blah
#t(1) - blah
#t(2) - blah

BocoC 08-13-2001 03:58 AM

Say you have 2 strings:
setstring this.teststring,This is a test;
setstring this.teststring2,This is "a test";

Now, lets tokenize the first one:
tokenize #s(this.teststring);

This is what it returns:
#t(0) - This
#t(1) - is
#t(2) - a
#t(3) - test

Now, lets tokenize the second string:
tokenize #s(this.teststring2);

This is what it returns:
#t(0) - This
#t(1) - is
#t(2) - a test

As you can see, putting parenthesis around something tells tokenize to count everything inside the parenthesis as 1 token.

As for tokenize2, it will tokenize via space's AND the delimeters, so:

setstring this.teststring3,My computer's name is Samson;
tokenize2 s,#s(this.teststring3);

This is what it returns:
#t(0) - My
#t(1) - computer'
#t(2) - name
#t(3) - i
#t(4) - am
#t(5) - on

Hope that helps

NeoNPL 08-18-2001 12:40 AM

This is used in the guild managment NPC for kingdoms. I could look at the version i have. if i wasnt so lazy.

Xaviar 08-18-2001 09:56 AM

Quote:

Originally posted by NeoNPL
This is used in the guild managment NPC for kingdoms. I could look at the version i have. if i wasnt so lazy.
No..thats ok..I figured it out a while ago ;)

Slaktmaster 08-18-2001 05:57 PM

Xaviar, that name reminds me of Kaviar.

Xaviar 08-18-2001 09:42 PM

I think you mean Caviar...and you would be the third person to say that

Slaktmaster 08-18-2001 10:12 PM

base


All times are GMT +2. The time now is 11:46 PM.

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