mIRC Homepage
Posted By: Fattyshow Replacing line in text file by wildcard - 04/10/15 01:33 AM
Code:
write -w<$nick> requests.txt $2- $+ ( $+ $nick $+ )


This part finds the line where the user's nickname is written.
Then it inserts the new $2- with his nick.

How do I make this so it deletes the old line and replaces it with the new one instead of inserting?
Posted By: Nillen Re: Replacing line in text file by wildcard - 05/10/15 09:56 AM
$readn returns the line number which your wildcard search was matched, writing with -il $+ $readn will overwrite said line.
/help /write
Posted By: Wims Re: Replacing line in text file by wildcard - 08/10/15 12:45 PM
The line you used is correct to overwrite a line, here is an example:
Code:
alias test_write {
write -c test LINE1 $+ $crlf $+ LINE2 $+ $crlf $+ LINE3
write -w"LINE2" test NEWLINE2
echo -a $read(test,tn,1) -- $read(test,tn,2) -- $read(test,tn,3)
.remove test
}


Nillens: $readn is only filled after a $read() call, using /write -w is much much better, $read will open the file, check all the line, try to match them, then on a match, fills $readn, close the file. You would then use /write -l $readn, which would open the file, go to the $readn line, and replace it. In short, the whole $read part can be avoided, speeding up the processing greatly.
© mIRC Discussion Forums