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.

Variable does not take value

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Variable does not take value

Post by juanamores »

This script controls changes nicks.

Code: Select all

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

..................................................
#putmsg $debug_channel "variable previous nick = $oldnick" HERE $oldnick is set perfectly..

#dj database waiting timer
utimer 5
  • 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 :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

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.
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

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: Select all

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 !
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Code: Select all

  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: Select all

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 !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

When programmed it looks I was asleep. :oops:
I declared the variables backwards. :D :D :D :D
Thanks caesar and willyw by being more awake than me. :P
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 :)
Post Reply