mIRC Home    About    Download    Register    News    Help

Print Thread
#215959 18/10/09 12:45 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Hi

I've never really used the write command much, but I'm working on a script where I want to insert a line into a file. It seems pretty straightforward but the text always gets put in the last line of the file.

At first I made the line dynamic.

var %li_ = $lines(file.txt) - 1
write $+(-i,%li_) file.txt Testing

This should write the line "Testing" to the second to last line in the file, but it always puts it in the last line.

I;ve tried a static line number.

/write -i5 file.txt Testing

This writes to the last line as well...


Whats going on? What am I missing?

DJ_Sol #215960 18/10/09 12:53 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
-l indicates that you provide a line position; -i is only for insert (and not overwrite). Use both switches, like in the example
Originally Posted By: /help /write
/write -il5 c:\info.txt This line will be inserted at the 5th line in the file



Horstl #215962 18/10/09 12:54 AM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
oh lol I didnt even see the l >.< thanks!


Link Copied to Clipboard