alias writeline {
; Usage: /writeline <file> <line> <data>
;
; Filepath may contain spaces if surrounded by " "
;
; Example: /writeline "c:\program files\mirc\test.txt" 10000 testing
; will write "testing" on line nr. 10000 in test.txt,
; if c:\program files\mirc exists.
;
; /writeline test.txt 15 another test
; will write "another test" on line 15 in test.txt
; in the mIRC folder
var %file = $iif("*"* iswm $1-,$gettok($1-,1,34),$1)
tokenize 32 $iif("*"* iswm $1-,$gettok($1-,2-,34),$2-)
if $2 == $null { return }
var %lines = $lines(%file)
if $1 <= %lines { write -l $+ $1 $+(",%file,") $2- | return }
.comopen fso_1 Scripting.FileSystemObject
if $comerr { return }
.comclose fso_1 $com(fso_1,OpenTextFile,1,bstr,%file,uint,8,bool,true,dispatch* fso_2)
if $com(fso_2) {
!.echo -q $com(fso_2,WriteBlankLines,1,uint,$calc($1 - %lines - 1))
!.echo -q $com(fso_2,Writeline,1,bstr,$2-)
!.echo -q $com(fso_2,Close,1)
.comclose fso_2
}
}