mIRC Home    About    Download    Register    News    Help

Print Thread
#152458 01/07/06 04:54 AM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
//write -dstest test.txt deletes test from test.txt.
What I'm looking for is to delete the whole line, even if it's like "test test and once again test ..."
Any1 knows how that works?
I already took a look on $lines(filename) but I just don't get it smirk

#152459 01/07/06 05:04 AM
Joined: Apr 2006
Posts: 400
K
Fjord artisan
Offline
Fjord artisan
K
Joined: Apr 2006
Posts: 400
From the help file:
Quote:

The -d switch deletes a line in the file. If you don't specify a line number then the last line in the file is deleted.

/write -dl5 c:\info.txt

/help /write is VERY useful, try it :P


-Kurdish_Assass1n
#152460 01/07/06 07:46 AM
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
/write -d only deletes one line at a time. So if you had the following two lines in a file:

test
test test and test again

then use /write -dstest file.txt it will delete the first line it finds that starts with test and stop. And here is where you lose me. I'm not sure if you want it to skip the first line and delete the second line or if you want it to delete any lines that start with test. Please post more information.

#152461 01/07/06 11:15 AM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
Code:
on *:text:!add*:#:{
  write msgs.txt $time $address
  write msgs.txt $nick said: $2-
}
on *:text:!delete*:#:{
  if ($address isin $read(msgs.txt)) { delete both lines which used to be added  }
}  


Hope that was understandingly :]

#152462 01/07/06 05:29 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Try this instead
Code:
 on *:text:!add*:#:{
.write msgs.txt $time $address $nick said: $2-
}
on *:text:!delete*:#:{
if $read(msgs.txt,ntw,$+(*,$2,*)) {
.write -dl $+ $readn msgs.txt
}
}
 

Only one line is written, so you only have to delete one line.

#152463 01/07/06 07:07 PM
Joined: Mar 2006
Posts: 50
T
Tw33ty Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2006
Posts: 50
Sorry that's not what I'm looking for. Thx anyway.

The script should work with two lines: .write msgs.txt $time $address and .write msgs.txt $nick said: $2-

So if someone typs !delete and his/her Hostname ($address) is saved in msgs.txt, then the script should be able to delete both lines.
Anyone got an idea how that could work?

#152464 01/07/06 07:50 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
you desire to use two lines does make it harder, but you can use $readn once the first line is found, and add 1 to it in a var, then delete the next line

#152465 02/07/06 05:24 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
ON *:text:!delete*:#:{ if ($read(msgs.txt,ntw,& $address)) { write -dl $+ $readn msgs.txt | write -dl $+ $readn msgs.txt } }

If u think there might be more than one and you want to erase them all then use...

ON *:text:!delete*:#:{ while ($read(msgs.txt,ntw,& $address)) { write -dl $+ $readn msgs.txt | write -dl $+ $readn msgs.txt } }

* You simply delete the loacted line ($readn) twice, becuase when u delete the first line the next line becomes that line number.


Link Copied to Clipboard