egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SpamScan
Goto page Previous  1, 2
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Jul 08, 2005 2:12 pm    Post subject: Reply with quote

well, the arrays is Tcl are associative per se, i.e. able to store key/value pairs, not limited to integer type key/index as most compiled languages

here's what I had in mind:
Code:

[demond@whitepine demond]$ cat test.tcl
proc countwords str {
  global count
  set idx 0
  while {1} {
    set buf [string range $str $idx end]
    if {[scan $buf %s word] > 0} {
      incr idx [expr [string first $word $buf] + [string length $word]]
      if {[info exists count($word)]} {incr count($word)} {set count($word) 1}
    } {break}
  }
}
[demond@whitepine demond]$ tclsh8.4
% source test.tcl
% set a "abc def   \t123\n  xyz\tabc\nabc     123\t"
abc def         123
  xyz   abc
abc     123
% countwords $a
% array get count
123 2 abc 3 xyz 1 def 1
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber