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 

File Opperations help

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


Joined: 05 Oct 2008
Posts: 19

PostPosted: Mon Nov 17, 2008 3:55 pm    Post subject: File Opperations help Reply with quote

First off, say you had this:
Code:


thing1 disc
thing2 disc
thing3 disc
thing4 disc


I would like to add a new line but if the line that i want to add starts with thing1 for example instead of adding it again at the end i want to update the existing thing1
also how could you delete a line by using lsearch but by searching the first word in each line so i would like to delete things3 for example by searching for thing3

secondly, say you had that same table, I want to be able to do a command and have it pull the first word from every line and list it in the channel ex: <bot> thing1, thing2, thing3, thing4

thanks to anyone who helps me with this.
Back to top
View user's profile Send private message
game_over
Voice


Joined: 26 Apr 2007
Posts: 29

PostPosted: Tue Nov 18, 2008 2:37 pm    Post subject: Reply with quote

when i whant to delete line in file i use foreach

see when you find line who starts for example thing1 you replase whit new and dont write again.

firest you read txt split to lines "\n"

and foreach line you set some if

when if is false "== 0" you write old line when is true "==1" you write new line

in this sense if you whant to delete some line just miss them

if {[lindex $lineforomtheforech 0] == "thing1"} {;# do nothing} else {puts "$lineforomtheforech"; #same line is writen again}


first row seems to look this way
Code:

set listforfirstrow ""
set opentxt [open $sometxt "r"]; set format [split [read $opentxt] "\n"]; close $opentxt

forech firstrow $format {
 set listforfirstrow "$listforfirstrow [lindex $firstrow 0]"
}

putquick "PRIVMSG $chan : $listforfirstrow"
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