mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2008
Posts: 24
W
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Hey all,

Im wanting to be able to delete a line from a text file. Currently im trying to use:
Code:
/write -d textfile.txt

I want the alias to remove a line based on my $1.
Eg. /removeline Nickname, should remove the line containing nickname regardless of where in the file it is.

Any help will be greatly appreciated.


=======================
Count WhipLash
Services Administrator
KnightNet
=======================
Joined: Oct 2007
Posts: 214
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
I hope this helps:

Code:
;usage $remove_line(<textfile.txt>,<nickname>)

alias remove_line {
  var %rem = $read($1,w,$+(*,$2,*))
  if (!%rem) { echo -a ***** Error! - $chr(91) $+(,$2,) $chr(93) is not listed in $1 ***** | halt }
  elseif (%rem) { 
    write $+(-dl,$readn) $1
    echo -a ***** $chr(91) $+(,$2,) $chr(93) has been removed from the textfile. ***** 
  }
}


Cheers,

Jay

Joined: Jul 2008
Posts: 24
W
Ameglian cow
OP Offline
Ameglian cow
W
Joined: Jul 2008
Posts: 24
Thanks Buggs2008. I did find an easier way while i was waiting for some help. Sorry.

Code:
 /write -ds $+ $1 textfile.txt 


Though your's does have extra stuff in which i havent got to fiddling with yet. Thanks for the help smile


=======================
Count WhipLash
Services Administrator
KnightNet
=======================

Link Copied to Clipboard