Difference between revisions of "$0"
From Scriptwiki
m (typo) |
|||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Remote Identifiers]] | [[Category:Remote Identifiers]] | ||
− | The identifier $0 is used in conjunction with [[$1-|$1]]. Technically it returns the number of tokens in the parameter passed. Unless the [[tokenize]] command has been used this defaults to being spaces, hence $0 will return the number of words in most cases. | + | The identifier $0 is used in conjunction with [[$1-|$1]]. Technically it returns the number of tokens in the parameter passed. Unless the [[tokenize]] command has been used this defaults to being spaces for commands and commas in identifers, hence $0 will return the number of words in most cases. |
== Examples == | == Examples == | ||
Line 11: | Line 11: | ||
Usage: /count_words Here is a sentence I want to count the words in.. | Usage: /count_words Here is a sentence I want to count the words in.. | ||
− | When used in an [[Events|event]] it acts the same. | + | When used in an [[:Category:Events|event]] it acts the same. |
[[On_text|on *:text]]:!count *:#mirc:{ [[msg]] [[$chan]] That was $0 words } | [[On_text|on *:text]]:!count *:#mirc:{ [[msg]] [[$chan]] That was $0 words } | ||
Line 17: | Line 17: | ||
Usage: !count Here's another sentence we want to have fun with! | Usage: !count Here's another sentence we want to have fun with! | ||
− | '''Note''' that $0 returns total number of tokens, meaning that in the event example above it will also count the word !count as being part of the sentence. This is not the case for the alias. | + | '''Note''' that $0 returns total number of tokens, meaning that in the event example above it will also count the word !count as being part of the sentence. You can bypass this by using [[$calc]]($0 - 1). This is not the case for the alias. |
− | |||
− | |||
− | |||
[[Category:Remote Identifiers]] | [[Category:Remote Identifiers]] |
Latest revision as of 23:12, 30 October 2008
The identifier $0 is used in conjunction with $1. Technically it returns the number of tokens in the parameter passed. Unless the tokenize command has been used this defaults to being spaces for commands and commas in identifers, hence $0 will return the number of words in most cases.
Examples
When used in an alias it can look something like this.
alias count_words { echo -a That was $0 words }
Usage: /count_words Here is a sentence I want to count the words in..
When used in an event it acts the same.
on *:text:!count *:#mirc:{ msg $chan That was $0 words }
Usage: !count Here's another sentence we want to have fun with!
Note that $0 returns total number of tokens, meaning that in the event example above it will also count the word !count as being part of the sentence. You can bypass this by using $calc($0 - 1). This is not the case for the alias.