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.

(re)loading single tcl files

Old posts that have not been replied to for several years.
Locked
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

(re)loading single tcl files

Post by De Kus »

Beware, if you have any faith, dont read the script. This script is very very old... but it worked almost perfect all the time :D.

Code: Select all

#	#	#	#	#	#	#	#	#
# .loactcl
#

bind dcc n loadtcl loadtcl

proc loadtcl {hand idx args} {
  source scripts/$args.tcl
  return 1
}
I know, this is really really ugly. I dont even know, if I load the memory till ultimo, but however it loads the procs and overwrites the old one. The only real flaw is, that variables used outside of a proc are not considered as global. I thought about using utimer to execute "source" globally, but I wonder if there isnt a more suitable command for that purpose? I couldnt find something in the tcl command list myself.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: (re)loading single tcl files

Post by user »

uplevel #0
    Have you ever read "The Manual"?
    User avatar
    De Kus
    Revered One
    Posts: 1361
    Joined: Sun Dec 15, 2002 11:41 am
    Location: Germany

    Re: (re)loading single tcl files

    Post by De Kus »

    user wrote:uplevel #0
      hmm, ah thats how its meant to be used. ic, thx. this way the global var prob should be solved.
      does someone know if the code will be double in memory, or will the procs be replaced not only in function but also in memory?
      De Kus
      StarZ|De_Kus, De_Kus or DeKus on IRC
      Copyright © 2005-2009 by De Kus - published under The MIT License
      Love hurts, love strengthens...
      User avatar
      user
       
      Posts: 1452
      Joined: Tue Mar 18, 2003 9:58 pm
      Location: Norway

      Re: (re)loading single tcl files

      Post by user »

      Things that are overwritten in the interpreter cease to exist
      Have you ever read "The Manual"?
      User avatar
      awyeah
      Revered One
      Posts: 1580
      Joined: Mon Apr 26, 2004 2:37 am
      Location: Switzerland
      Contact:

      Post by awyeah »

      I would suggest another thing by opening the .conf file going to the end and writing:

      source scripts/$text.tcl

      You will have to search for the last line in this case and then in the next "/n" empty line write down so that it loads. In this will always make it stay there untill you remove it.

      Then make your proc execute a rehash:

      utimer 2 rehash
      ·­awyeah·

      ==================================
      Facebook: jawad@idsia.ch (Jay Dee)
      PS: Guys, I don't accept script helps or requests personally anymore.
      ==================================
      User avatar
      user
       
      Posts: 1452
      Joined: Tue Mar 18, 2003 9:58 pm
      Location: Norway

      Post by user »

      awyeah wrote:bla bla bla
      utimer 2 rehash
      'open file a' would make sure you're at the end...but adding a new 'source filename' every time you want to REload a script is not a good idea and detecting if the file is already added to the conf can be hard as it could be sourced in many ways. And why wait 2 seconds to rehash? Just rehash after you've closed the file.
      De Kus wrote:hmm, ah thats how its meant to be used. ic, thx. this way the global var prob should be solved.
      :idea: A even better method would be to replace "uplevel #0" with "*dcc:tcl <handle> <idx>" - that way it will also honor your must-be-owner setting.
      Have you ever read "The Manual"?
      User avatar
      awyeah
      Revered One
      Posts: 1580
      Joined: Mon Apr 26, 2004 2:37 am
      Location: Switzerland
      Contact:

      Post by awyeah »

      Sometimes the bot laggs on the shell and there can be various problems so using a small delayed utimer was my idea.

      As for the 'uplevel' thingy, for me lets stay we'll stick to the simple method at the moment. :)
      ·­awyeah·

      ==================================
      Facebook: jawad@idsia.ch (Jay Dee)
      PS: Guys, I don't accept script helps or requests personally anymore.
      ==================================
      User avatar
      user
      &nbsp;
      Posts: 1452
      Joined: Tue Mar 18, 2003 9:58 pm
      Location: Norway

      Post by user »

      awyeah wrote:As for the 'uplevel' thingy, for me lets stay we'll stick to the simple method at the moment. :)
      what method is that?
      Have you ever read "The Manual"?
      User avatar
      De Kus
      Revered One
      Posts: 1361
      Joined: Sun Dec 15, 2002 11:41 am
      Location: Germany

      Post by De Kus »

      Haha, rehash... I could do this myself, but in case of debugging I have to reload my script often 10 times a row and always waiting 10sec till bot it rehashed is simply boring. So users uplevel solution is the best. Please only post, if you know a better solution than "source" :).
      for security... if someone hacks my dcc password, there is no worry about loading an extra script over dcc, since he cannot upload to /script without a trojaner on my machine :D. there you be no way to load from another path, because "script/*.tcl" is predefined, is there? :) I havent tested, if a containing [] would be executed, but I think it wouldnt, would it? but... even it would... when he has +n on partyline with my account he already has access to .tcl anyway... its useless to think about it :).
      De Kus
      StarZ|De_Kus, De_Kus or DeKus on IRC
      Copyright © 2005-2009 by De Kus - published under The MIT License
      Love hurts, love strengthens...
      Locked