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 

Variable does not take value

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


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Nov 08, 2016 6:50 am    Post subject: Variable does not take value Reply with quote

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. Confused
_________________
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 Smile
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Tue Nov 08, 2016 8:42 am    Post subject: Reply with quote

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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Nov 08, 2016 10:06 am    Post subject: Reply with quote

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. Smile
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
View user's profile Send private message
willyw
Revered One


Joined: 15 Jan 2009
Posts: 1175

PostPosted: Tue Nov 08, 2016 10:09 am    Post subject: Reply with quote

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
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Nov 08, 2016 7:11 pm    Post subject: Reply with quote

When programmed it looks I was asleep. Embarassed
I declared the variables backwards. Very Happy Very Happy Very Happy Very Happy
Thanks caesar and willyw by being more awake than me. Razz
_________________
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 Smile
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