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.

Time problem?

Help for those learning Tcl or writing their own scripts.
Post Reply
p
pektek
Halfop
Posts: 51
Joined: Sat Jul 01, 2023 4:51 pm

Time problem?

Post by pektek »

I'm getting error

[10:19:01] Tcl error in script for 'timer1':

Code: Select all

# channel to cycle
set cyclechan "#blabla"

# minutes between each cycle
set timecycle 120 

# minutes to idle before rejoining chan
set timewait 1

bind RAW * 366 cyclestart

proc cyclestart { from key arg } {
global cyclechan timecycle
        set chan [lindex [split $arg] 1]
        if { $chan != $cyclechan } { return 0 }
        timer $timecycle cycle
}

proc cycle { } {
global scanchan timewait
        channel set $cyclechan +inactive
        timer $timewait "channel set $cyclechan -inactive"
}
D
DasBrain
Voice
Posts: 19
Joined: Thu Apr 08, 2021 12:31 pm

Re: Time problem?

Post by DasBrain »

You use the variable cyclechan in your proc cycle, but that variable is not listed in the global, or a parameter, or set anywhere.

Did you mean scanchan? Or did you mean cyclechan in the global statement?
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Time problem?

Post by CrazyCat »

You'd better try:
timer $timewait [list channel set $cyclechan -inactive]
And when an error occures, think to type .set errorInfo to have more informations about it

DasBrain is true too: you don't have $cyclechan in this proc
p
pektek
Halfop
Posts: 51
Joined: Sat Jul 01, 2023 4:51 pm

Re: Time problem?

Post by pektek »

I'm getting an error

[00:26:01] Tcl error in script for 'timer1':
[00:26:01] can't read "cyclechan": no such variable

Code: Select all

# channel to cycle
set cyclechan "#Sohbet"

# minutes between each cycle
set timecycle 2 

# minutes to idle before rejoining chan
set timewait 1

bind RAW * 366 cyclestart

proc cyclestart { from key arg } {
global cyclechan timecycle
        set chan [lindex [split $arg] 1]
        if { $chan != $cyclechan } { return 0 }
        timer $timecycle cycle
}

proc cycle { } {
global scanchan timewait
        channel set $cyclechan +inactive
        timer $timewait [list channel set $cyclechan -inactive]
}
User avatar
CrazyCat
Revered One
Posts: 1301
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: Time problem?

Post by CrazyCat »

That's the thing DasBrain explained. $cyclechan is not defined in cycle proc. Add it in your global, or use $:: namespace
# channel to cycle
set cyclechan "#Sohbet"

# minutes between each cycle
set timecycle 2 

# minutes to idle before rejoining chan
set timewait 1

bind RAW * 366 cyclestart

proc cyclestart { from key arg } {
        global cyclechan timecycle
        set chan [lindex [split $arg] 1]
        if { $chan != $cyclechan } { return 0 }
        timer $timecycle cycle
}

proc cycle { } {
        global scanchan cyclechan timewait
        channel set $cyclechan +inactive
        timer $timewait [list channel set $cyclechan -inactive]
}
Post Reply