mIRC Home    About    Download    Register    News    Help

Print Thread
Word Count #112700 26/02/05 06:09 AM
Joined: Oct 2003
Posts: 80
R
RockHound Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Oct 2003
Posts: 80
What is the best way to count the words in $1-? I currently can only think of counting spaces between the words. However a user could add 2 spaces and would be inaccurate. Ideas Please


RockHound
Re: Word Count #112701 26/02/05 06:11 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
$0 = the number of $N's smile

Re: Word Count #112702 26/02/05 06:14 AM
Joined: Oct 2003
Posts: 80
R
RockHound Offline OP
Babel fish
OP Offline
Babel fish
R
Joined: Oct 2003
Posts: 80
Ty Lori I never knew that before


RockHound
Re: Word Count #112703 26/02/05 06:29 AM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
mIRC eliminates the 2nd occurance of $chr(32) (space).
Code:
I type //echo -a $gettok(hello     how     are     you     doing     today?,0,32)

It returns 6 which is the number of words.

I type //echo -a $numtok(hello     how     are     you     doing     today?,32)

Will also return 6.


On *:Text:*:#: {
  echo -a $gettok($1-,0,32) words.
  echo -a $numtok($1-,32) words.
  echo -a $0 words.
}