Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2007, 05:47 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Spaces

PHP Code:
public function removeAllSpaces(text) {
  
temp.toks text.tokenize();
  for (
temp.str temp.toks) {
    if (
temp.str == " ") {
      continue;
    }
    
temp.out @= temp.str;
  }
  return 
temp.out.trim();
}
//#CLIENTSIDE
public function removeAllSpaces(text) {
  
temp.toks text.tokenize();
  for (
temp.str temp.toks) {
    if (
temp.str == " ") {
      continue;
    }
    
temp.out @= temp.str;
  }
  return 
temp.out.trim();

This removes all spaces everywhere on a join. A simple usage of this would be something like.

PHP Code:
function onCreated() {
  
join("util_spaces");
  
temp.string " Lollin @ Chompy";
  echo(
removeAllSpaces(temp.string));

^ That would echo: "Lollin@Chompy";
Just for some of those minor irritations that are too minor to add a built in function for.
__________________
Stan.
Reply With Quote
  #2  
Old 08-28-2007, 06:04 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
I don't think spaces are included in the return from tokenize(); In the end, you could easily loop the array without the need to check for spaces.
Reply With Quote
  #3  
Old 08-28-2007, 06:11 PM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Err, well I'll check it out later. I think it is tho, not sure.

Edit: Actually you're right because space is the delimiter. Thanks Twinny. ;P
__________________
Stan.
Reply With Quote
  #4  
Old 08-28-2007, 06:20 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
<3

PHP Code:
public function removeSpaces(str) {
  
temp.out 0;
  for(
temp.str.tokenize()) out @= t;
  return 
out;

Oh, and lol back at you
<3
__________________
Reply With Quote
  #5  
Old 08-29-2007, 03:27 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by Chompy View Post
<3

PHP Code:
public function removeSpaces(str) {
  
temp.out 0;
  for(
temp.str.tokenize()) out @= t;
  return 
out;

Oh, and lol back at you
<3
<3
__________________
Stan.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:43 PM.


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