Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-09-2007, 09:48 AM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
Split String Into Separate Characters?

Hey how do I split a string into separate characters using a function similar to tokenize?
Reply With Quote
  #2  
Old 07-09-2007, 11:54 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I'm not sure if there is a function to split a string into an array by characters. I made an example one for you.

PHP Code:
function onCreated()

  
this.string "Splitting a string by characters";
  
temp.array = splitstring(this.string);
  echo(
temp.array);
}

function 
splitstring(string)
{
  for (
t=0string.length(); t++)
  {
    if (
string.substring(t,1) != " ")
    {
      
temp.array.add(string.substring(t,1));
    }  
  }
  return 
temp.array;

Echo'd 'S,p,l,i,t,t,i,n,g,a,s,t,r,i,n,g,b,y,c,h,a,r,a,c,t ,e,r,s'. I didn't add spaces by default but you can change that if need be. Hope this helps.
Reply With Quote
  #3  
Old 07-09-2007, 12:25 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
temp.t Please!
__________________
Do it with a DON!
Reply With Quote
  #4  
Old 07-09-2007, 01:03 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by zokemon View Post
temp.t Please!
For() loops should automatically make the variables temporary ones...
Reply With Quote
  #5  
Old 07-09-2007, 04:15 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Twinny View Post
For() loops should automatically make the variables temporary ones...
Oh? I've been in such a habit to spam temp. everywhere that I see that I would have no way of knowing this.
__________________
Do it with a DON!
Reply With Quote
  #6  
Old 07-11-2007, 10:53 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by zokemon View Post
Oh? I've been in such a habit to spam temp. everywhere that I see that I would have no way of knowing this.
That's what I do.

on Java,

PHP Code:
for ( int i 05++ ) 
the variable 'i' is contained in the for and is not made global like if you were to do:

PHP Code:
int i;
for ( 
05++ ) 
Perhaps Graal does something similar?
__________________
Reply With Quote
  #7  
Old 07-12-2007, 12:18 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by cbkbud View Post
...

Perhaps Graal does something similar?
I think Graal scopes variables to the function, not to the block.
__________________
Skyld
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 01:32 AM.


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