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.

Question about lists

Old posts that have not been replied to for several years.
Locked
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Question about lists

Post by XceL »

I need some help with some code. When I use this it just gives me the same results each time, which is:
[21:00] <@********> 0 Files before update.
[21:00] <@********> 3 Files after update.
[21:00] <@********> File database updated succesfully. There were 3 Files added and 0 Files removed.

Code: Select all

proc update {nick uhost hand chan text} {
  set fdb [open /home/xcel/eggdrop/filesys/fs a+]
  set data [read $fdb]
  close $fdb
  set afs 0
  set rfs 0
  set lines [split $data \n]
  putquick "privmsg $chan :[llength $lines] Files before update."
  foreach file [glob /home/xcel/eggdrop/filesys/*.url] {
    if {[lsearch lines $file] == -1} {
      lappend lines $file|[file atime $file]
      incr afs
    }
  }
  putquick "privmsg $chan :[llength $lines] Files after update. $lines"
  set fdb [open /home/xcel/eggdrop/filesys/fs w]
  foreach element $lines {
    puts $fdb "$element"
  }
  close $fdb
  set line1 "File database updated succesfully."
  set line2 "There were $afs Files added and $rfs Files removed."
  putquick "privmsg $chan :$line1 $line2"
}
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

set fdb [open /home/xcel/eggdrop/filesys/fs a+]
this sets the file pointer after EOF; you need to read from the beginning:

Code: Select all

set fdb [open /home/xcel/eggdrop/filesys/fs r]
also:

Code: Select all

if {[lsearch lines $file] == -1}
should be:

Code: Select all

if {[lsearch $lines $file*] == -1}
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Post by XceL »

Thanks, I had the a+ switch on there for it to create the file at first. Then removed it.
X
XceL
Voice
Posts: 20
Joined: Wed Jan 14, 2004 8:57 pm

Post by XceL »

Trying not to clutter up the forums too bad, but this question relates to the script. I have the list of files be inputed into a text file, followed by a carraige return then dcced to the user, if desplayed in notepad why is it a block and not a new line? Thanks, the code to input into the file looks like this.

Code: Select all

      puts $file [join $flist "\n"]
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

i think its to do with notepad's format. Use Wordpad, its alot better.
r0t3n @ #r0t3n @ Quakenet
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

You should not really use wordpad or word for that matter when writing scripts. There are good programs out there which are available to use, some free some not. I Personally use EditPlus 2 to work with TCL / PHP / HTML etc etc and is an awsome client. I do however use Notepad++ which is freeware and open source which you can download from here. This does pretty much exaclty what EditPlus2 does but its free. Trust me when i say once you have used these programs you will never go back to notepad / wordpad ever again :wink:
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I personally only like wordpad :P
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

EditPlus 2 is my all time favourite; been using it for at least 4 years now. The document format feature (among many) is excellent. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

for a complex Tcl project, using a programmer's editor like emacs, with syntax highlighting etc, is a necessity

for a simple eggdrop script (99% of bot scripts would classify in that category), Notepad will suffice
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

EditPlus2 and notepad++ both have syntax hilighting and auto indent features, the list goes on. Great if your not used to or have a linux box to play with emacs ;)
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Locked