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 

Insert Line After Regular Interval

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


Joined: 29 Nov 2005
Posts: 10

PostPosted: Wed Jun 07, 2006 11:54 am    Post subject: Insert Line After Regular Interval Reply with quote

If this is covered somewhere else then please direct me there because i couldnt find it.

I am trying to insert a line in a text file, starting after a certain line and then at regular intervals till eof.

Not to mention that this works in a wierd way.

Code:

proc main {nick host hand chan rest} {
   global opfile
   set logfile [open $opfile(list) r]
   set lines [split [read -nonewline $logfile] "/n"]
   set totlines [llength $lines]
   set fp [open $opfile(final) a]
   set num 7
   while {$num <= $totlines} {
      set lines [linsert $lines $num $opfile(insert)]
      puts $fp [join $lines "\n"]
      set num [expr {$num + 5}]
   }
   close $fp
   close $logfile
}


Any help ?
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Jun 07, 2006 12:09 pm    Post subject: Reply with quote

1. read the file into list in memory
2. manipulate the list using [linsert] or [lreplace]
3. write the list back to disk file
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
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