This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

utimers returns nothing?

Help for those learning Tcl or writing their own scripts.
Post Reply
d
desired
Voice
Posts: 31
Joined: Mon Sep 12, 2011 5:17 pm

utimers returns nothing?

Post by desired »

utimers when called with .tcl partyline it shows a list with all utimers.

But when I call utimers from another proc which gets invoked by a bind it returns always nothing. Even when there are still utimers (which I see, I tested to type .tcl utimers on partyline again).

Why is that?

I also testet set utimers [uplevel #0 { utimers }], still didn't work.

How can I get them?
eggdrop running on Android powered mobile phone - Yes, it is possible! - Very reliable.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: utimers returns nothing?

Post by willyw »

Can you post your script so we can see it?
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: utimers returns nothing?

Post by willyw »

desired wrote: ...
I also testet set utimers [uplevel #0 { utimers }], still didn't work.
...
Have you tried it with square brackets?
i.e. [utimers]
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

desired,
this sounds like a bug to me. However, I am not able to reproduce it myself. What kind of binding did you use?

As for uplevel, the context of where utimers is invoked should not matter, as timers are always stored and accessed on a global scope.

willyw,
For that piece of code to work as expected, one should NOT use square brackets. The idea is for the code block to be evaluated at a different context than the current - which is why we do not want any command substitutions done in the current context.
NML_375
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

nml375 wrote: ...
For that piece of code to work as expected, one should NOT use square brackets.
...

Ok.
d
desired
Voice
Posts: 31
Joined: Mon Sep 12, 2011 5:17 pm

Post by desired »

Thanks for all your help.

Ok, I was able to reproduce it. Here is a script which I wrote to show you the error. It has been tested and hopefully I did not mess up and you can reproduce it.

Code: Select all

proc isutimer_ { id } {
	foreach utimer [utimers] {
		set isid [lindex $utimer 2]
		if { $id == $isid } {
			return 1
		}
	}
	return 0
}

bind dcc nm|- test test_dcc

proc test_dcc { args } {
	putlog "test_dcc::: utimers: [utimers]"
	putlog "test_dcc::: isutimer $::re_utimer: [isutimer_ $::re_utimer]"
	utimer 1 [list test_dcc_show]
}

proc test_dcc_show { } {
	putlog "test_dcc_show::: utimers: [utimers]"
	putlog "test_dcc_show::: isutimer $::re_utimer: [isutimer_ $::re_utimer]"
}

proc test_re { } {
	putlog "test_re ..."
	set ::re_utimer [utimer 10 [list test_re]]
}

if { ! [info exists ::re_started] } {
	set ::re_started 1
	test_re
}
Results:
test_dcc will show everything correctly but test_dcc_how will not know anything about utimers anymore...
eggdrop running on Android powered mobile phone - Yes, it is possible! - Very reliable.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Unfortunately, that code will not cause the described behavior on a 1.6.21 eggdrop I just tested it on.
NML_375
d
desired
Voice
Posts: 31
Joined: Mon Sep 12, 2011 5:17 pm

Post by desired »

EDIT:
I am on 1.8.
Last edited by desired on Sat Dec 17, 2011 10:20 pm, edited 1 time in total.
eggdrop running on Android powered mobile phone - Yes, it is possible! - Very reliable.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

desired wrote:I am on 1.9.
Really??!
Did you miss the memo??!

1.9 is dead. Has a fork sticking out of it. Why are you using it?

Try 1.6.21 or 1.8 .. These at least are still in development. :wink:
d
desired
Voice
Posts: 31
Joined: Mon Sep 12, 2011 5:17 pm

Post by desired »

I mean 1.8. Sorry!

(used this: http://www.eggheads.org/devel/)
eggdrop running on Android powered mobile phone - Yes, it is possible! - Very reliable.
Post Reply