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 

i really need ur help... tcl list

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
myWorldTCL
Voice


Joined: 31 Jul 2008
Posts: 5

PostPosted: Thu Jul 31, 2008 5:24 am    Post subject: i really need ur help... tcl list Reply with quote

i run this code in dmh console...
Code:
while {[string match \{*\} $mbxmsg] && [llength $mbxmsg]==1} {
      set list [lindex $mbxmsg 0]
      
   }
      return [list $mbxmsg]
      
      set a [lindex $mbxmsg 0]
      set b [llength $mbxmsg]
      while {$a < $b} {   
         set x [linsert $a $b]
         puts "[localtime 9], $x"
         incr b
         mbx whenmsg again
   }



then insert the list {{1 2 3} {4 5 6}}.. there has no output display.. whats the problem???
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Jul 31, 2008 5:48 am    Post subject: Reply with quote

There's no need to double-post.
'return' returns (the lines below are never executed) ...also, your code doesn't make much sense to me. It would be easier to help you if you explain exactly what you are trying to do.
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
myWorldTCL
Voice


Joined: 31 Jul 2008
Posts: 5

PostPosted: Thu Jul 31, 2008 10:06 am    Post subject: i want to display both of list Reply with quote

regarding to my question, i want to display both of list: {{1 2 3} {4 5 6}}
the coding is same as above... i have post before this.. then i execute the source file... and execute both of list {{1 2 3} {4 5 6}}, but there has no result display for both of list....


my question is, how to display more than one list??? let say if i execute three list like this: {{1 2 3} {4 5 6} {7 8 9}}?? maybe you can help me to correct my coding... im new of using this tcl..
Back to top
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Thu Jul 31, 2008 10:18 am    Post subject: Re: i want to display both of list Reply with quote

Sorry for the delay... we had a power failure at work.
Code:
foreach sublist $listOfLists {
   # do something to $sublist
}

...and you probably want to replace 'puts' with 'putlog' if you're running this script in an eggdrop. Wink
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
myWorldTCL
Voice


Joined: 31 Jul 2008
Posts: 5

PostPosted: Thu Jul 31, 2008 10:32 am    Post subject: i still not get it Reply with quote

can u show me the real thing?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jul 31, 2008 11:13 am    Post subject: Reply with quote

I find it very hard to figure out what the "real thing" would be. The code you posted is not only confusing, but riddled with bugs. All I've gathered is that you are trying to use "DMH Mailbox messaging"?

First off, you have a while-loop that will run as long as $a (the first list item of the recieved message) is smaller than $b, which is increased for each iteration of the loop. Hence you have a possible infinite loop.

Next, you use linsert with $a as list, and $b as index, yet you fail to supply an entity to add, causing a fatal error.

Finally, assuming those two items were fixed, you'd still end up writing the same line over and over, or possibly with added content for each iteration of the loop.


If you are working with a tcl-shell (tclsh or similar), use something like this to simply print the contents of the list:
Code:
foreach sublist $mbxmsg {
  puts $sublist
}

(With eggdrop, you'd simply replace puts with putlog to send the output to the log, or puthelp to build a command to send to the irc-server...)
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
myWorldTCL
Voice


Joined: 31 Jul 2008
Posts: 5

PostPosted: Thu Jul 31, 2008 12:19 pm    Post subject: i still not get it Reply with quote

yes im using DMH Mailbox messaging... so what shud i do to perform the code that u gave it to me juz now?
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu Jul 31, 2008 2:19 pm    Post subject: Reply with quote

First off, you'll have to explain what you wish to achieve...
Do you simply wish to dump the lists to stdout? If so, the code posted will do just that.
If you wish to do something more, explain it, because I have no clue what further processing you'd like to do...
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Jul 31, 2008 6:28 pm    Post subject: Reply with quote

Code:
while {[string match \{*\} $mbxmsg] && [llength $mbxmsg]==1} {
set list [lindex $mbxmsg 0]

}
return [list $mbxmsg]

It appears this part uses a while (why not an if?) to check to see if there are curly braces in the string, then checks the llength against a string?! which basically returns the 1 so of course =='s it. Then it sets the lindex to 0 to remove the curly bracings? Did it assume it was a list incorrectly? But wait, lower down it returns a list of one element consisting of the contents of $mbxmsg. This is an obvious horribly written kludge to turn a string into a list.
Code:
set a [lindex $mbxmsg 0]
set b [llength $mbxmsg]
Then lower down we have this code which treats it as list? then the rest of it makes no sense to me. And really none of the above does either, I can just tell why it was written. As nml375 said, to get more help you have to show more code. What is posted goes all over the place and leaves too much out.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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