mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2003
Posts: 29
2
2big Offline OP
Ameglian cow
OP Offline
Ameglian cow
2
Joined: Aug 2003
Posts: 29
Is there an identifier that returns the number of characters in a word, and a different identifier that returns the number of words in the event? If not, can someone help me make one?

Example:

on *:text:*:#: {
/msg $chan The number of letters/characters in your first words was $NumChar($1)
/msg $chan the number of words in your statement was $NumWords($1-)
}


Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
$len() and $0
This will do what you asked, but it will send two lines to the chan for every line others send, so you will likely flood off if it is a busy channel
Code:
on *:text:*:#:{
  msg # The number of letters/characters in your first words was $len($strip($1))
  msg # the number of words in your statement was $0
}
$len($strip($1)) will remove any control chars from the word before calculating the length.

Joined: Jan 2003
Posts: 119
A
AKO Offline
Vogon poet
Offline
Vogon poet
A
Joined: Jan 2003
Posts: 119
Use $len() to return characters.

If you want to do words, it depends. you'd have to get a little bit more complex. If you want to specify words based on spaces (the standard), then you could use tokens.

An example would be $numtok($1-,32) would return the number of different 'words' in a string using spaces as the seperator. Of course, you could run into problems and would have to be a little more complicated on the code if you did say, the following:

how are you ?

It would count the ? as an extra word, because of the space there.


Link Copied to Clipboard