| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Tue Nov 08, 2016 6:50 am Post subject: Variable does not take value |
|
|
This script controls changes nicks.
| Code: | bind nick - * nickchange
set debug_channel "#debugs_tcl"
set Djs_channel #Djs_channel"
proc nickchange { oldnick uhost hand chan newnick } {
global debug_channel Djs_channel
if {[string tolower $chan] != [string tolower $Djs_channel]} {return 0}
#DJs data base
if {[file exists dj]} {
set temp [open "dj" r]
set djs [gets $temp]
set dj [lindex $djs 0]
close $temp
}
#putmsg $debug_channel "variable previous nick = $oldnick"
#dj database waiting timer
utimer 5 [list vDJ oldnick uhost hand chan newnick Djs_channel dj]
proc vDJ {$oldnick $uhost $hand $chan $newnick $Djs_channel $dj} {
if {([info exist dj]) && ([info exist oldnick]) && ($oldnick == "$dj")} { putmsg $Djs_channel "$newnick does not change its nickname while is on air. Thanks"
return
}
#DJs and Staff check flags
set hand [nick2hand $oldnick $chan]
if {[djs:check:flags $chan $hand]} { return
} else {
putmsg $Djs_channel "$newnick remember back to your nick..."
}
}
} |
ERROR:
[10:39:38] Tcl error in script for 'timer45':
[10:39:38] can't read "oldnick": no such variable
| Quote: |
..................................................
#putmsg $debug_channel "variable previous nick = $oldnick" HERE $oldnick is set perfectly..
#dj database waiting timer
utimer 5 [list vDJ oldnick uhost hand chan newnick Djs_channel dj]
proc vDJ {$oldnick $uhost $hand $chan $newnick $Djs_channel $dj} {
HERE can't read "oldnick": no such variable
|
I do not understand that the variable has value on the previous line and NOT in the next line.  _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Nov 08, 2016 8:42 am Post subject: |
|
|
That's because you forgot to add $ in front of the variable names. For example it should be $oldnick instead of oldnick. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Nov 08, 2016 10:06 am Post subject: |
|
|
| caesar wrote: | | That's because you forgot to add $ in front of the variable names. For example it should be $oldnick instead of oldnick. |
You mean in this line, right?
| Code: |
utimer 5 [list vDJ oldnick uhost hand chan newnick Djs_channel dj]
|
If so, I saw that too.
However, wouldn't that itself assign a value to the variable in the proc when called? Thus perhaps causing some other error, but not the one described?
I started to answer this post earlier, then after I re-thought it as just stated, I convinced myself that I was not awake yet, and to wait awhile.
I must be overlooking something .... _________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Nov 08, 2016 10:09 am Post subject: |
|
|
| Code: |
utimer 5 [list vDJ oldnick uhost hand chan newnick Djs_channel dj]
proc vDJ {$oldnick $uhost $hand $chan $newnick $Djs_channel $dj} {
|
Are these just backwards?
As in, should be:
| Code: |
utimer 5 [list vDJ $oldnick $uhost $hand $chan $newnick $Djs_channel $dj]
proc vDJ {oldnick uhost hand chan newnick Djs_channel dj} {
|
_________________ For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia ! |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Tue Nov 08, 2016 7:11 pm Post subject: |
|
|
When programmed it looks I was asleep.
I declared the variables backwards.
Thanks caesar and willyw by being more awake than me.  _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
|