Length: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>PhilmASTErpLus Added code sample and removed needscode=yes| |
||
Line 17: | Line 17: | ||
function_description=Returns the number of characters (not 0-indexed) in a string. Note that for escaped characters, only the actual character — not the escape marker — is counted.| | function_description=Returns the number of characters (not 0-indexed) in a string. Note that for escaped characters, only the actual character — not the escape marker — is counted.| | ||
code1={{CodeSample| | |||
title=Code Sample| | |||
description=The following example determines the number of characters in the name of a hat.| | |||
code=<syntaxhighlight> | |||
/* Assume string remove_spaces( item ) exists */ | |||
item the_hat = $item[ pail ]; | |||
string parsed_name = remove_spaces( the_hat ); | |||
if ( item_type( the_hat ) == "hat" && length( parsed_name ) == 4 ) | |||
print( "You can receive the +20ML buff from the Mad Tea Party." ); | |||
</syntaxhighlight>| | |||
moreinfo=Note that you can easily receive [http://kol.coldfront.net/thekolwiki/index.php/The_Mad_Tea_Party Mad Tea Party buffs] by using the <code>hatter</code> CLI command or the [[Helpful_Scripts#Buff_Upkeep_Scripts|hatter.ash]] script. | |||
}} | |||
}} | }} | ||
[[Category:String Handling Routines]] | [[Category:String Handling Routines]] |
Revision as of 03:08, 26 June 2010
Function Syntax
- count_me is the string to check
Returns the number of characters (not 0-indexed) in a string. Note that for escaped characters, only the actual character — not the escape marker — is counted.
Code Sample
The following example determines the number of characters in the name of a hat.
/* Assume string remove_spaces( item ) exists */
item the_hat = $item[ pail ];
string parsed_name = remove_spaces( the_hat );
if ( item_type( the_hat ) == "hat" && length( parsed_name ) == 4 )
print( "You can receive the +20ML buff from the Mad Tea Party." );
Note that you can easily receive Mad Tea Party buffs by using the hatter
CLI command or the hatter.ash script.