mIRC Home    About    Download    Register    News    Help

Print Thread
#98867 27/09/04 03:11 PM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
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.


i script, therefore i am smirk
theres logic in there somewhere...
#98868 27/09/04 03:17 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
/write -lN filename.txt text

overwrites line N

/write -ilN filename.txt text

inserts the line at position N


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98869 27/09/04 03:25 PM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
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


i script, therefore i am smirk
theres logic in there somewhere...
#98870 27/09/04 03:45 PM
Joined: Dec 2002
Posts: 145
G
Vogon poet
Offline
Vogon poet
G
Joined: Dec 2002
Posts: 145
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-

#98871 27/09/04 04:00 PM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
Ok that works fine, thanks.

I was worried that that switch would OVERWRITE line 1.

Thanks guys.


i script, therefore i am smirk
theres logic in there somewhere...
#98872 27/09/04 04:06 PM
Joined: Dec 2002
Posts: 145
G
Vogon poet
Offline
Vogon poet
G
Joined: Dec 2002
Posts: 145
You're welcome

As mentioned by LocutusofBorg

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

/write -il1 YourFileName $2- ;i => insert

#98873 27/09/04 07:45 PM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
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


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#98874 28/09/04 09:56 AM
Joined: Jul 2004
Posts: 40
D
dmmrs Offline OP
Ameglian cow
OP Offline
Ameglian cow
D
Joined: Jul 2004
Posts: 40
Ok, easy tiger smile

I apologise...

I may have not read it correctly, but it wasa simple mistake to make.


i script, therefore i am smirk
theres logic in there somewhere...
#98875 28/09/04 02:25 PM
Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788

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.


Link Copied to Clipboard