mIRC Homepage
Posted By: dmmrs /write command - 27/09/04 03:11 PM
Is there any way at all that instead of adding a line to the END of a txt file, I can add it to the start?

sometext
sometext2
sometext3

Say this is the text file above. I wanna /write sometext4, but i want it to write to above sometext, as opposed to below sometext3.

Is that possible?

Thanks in advance.
Posted By: LocutusofBorg Re: /write command - 27/09/04 03:17 PM
/write -lN filename.txt text

overwrites line N

/write -ilN filename.txt text

inserts the line at position N
Posted By: dmmrs Re: /write command - 27/09/04 03:25 PM
Ok, that doesn't help, although thanks smile

Lets say, for arguments sake, that its a top 5 uk singles chart. That the bset way i can explain it. I already have a trigger that on !text, will play the first 5 lines of the text file.

What i want is when someone types !add blahblah, it inserts the line blahblah at the TOP of the file, without deleting or replacing any other lines, so that the top 5 lines are always the most recently added via the !add command.

Does that make sense?

Say the file looks like this at the moment:

no1
no2
no3
no4
no5

And if i !add no6, then the txt file will look like this:

no6
no1
no2
no3
no4
no5
Posted By: gemeau50 Re: /write command - 27/09/04 03:45 PM
Quote:
What i want is when someone types !add blahblah, it inserts the line blahblah at the TOP of the file, without deleting or replacing any other lines


Event : on text

Format: on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>

On *:text:!add*:*: write -il1 YourFileName $2-
Posted By: dmmrs Re: /write command - 27/09/04 04:00 PM
Ok that works fine, thanks.

I was worried that that switch would OVERWRITE line 1.

Thanks guys.
Posted By: gemeau50 Re: /write command - 27/09/04 04:06 PM
You're welcome

As mentioned by LocutusofBorg

/write -l1 YourFileName $2- ;would overwrite line 1

/write -il1 YourFileName $2- ;i => insert
Posted By: LocutusofBorg Re: /write command - 27/09/04 07:45 PM
If you qwere worried about that, I suggest reading the help you were given better than you apparantly did. I specifically stated both the overwrite and insert options to prevent any confusion as to what the code might do. Nice to know I wasted another few minutes of my life frown
Posted By: dmmrs Re: /write command - 28/09/04 09:56 AM
Ok, easy tiger smile

I apologise...

I may have not read it correctly, but it wasa simple mistake to make.
Posted By: Coolkill Re: /write command - 28/09/04 02:25 PM

On *:Text:!add*:#:{ write -il1 [color:red]filename.txt
$$2- }
[/color]
is what you want, !add [color:red]text
[/color]
Although it might be worth mentioning, not to get the switches mixed up, '-i' must come before 'l' or it'll override.

Eamonn.
© mIRC Discussion Forums