mIRC Home    About    Download    Register    News    Help

Print Thread
/write stuff. #75501 16/03/04 07:06 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
Yeah. I'm trying to get /write to use the -w"Text" switch..so it searches the file for the line containing "Text" and perform the action on it..

It doesn't seem to be working..I'm using like this (for testing) right now:

/write -dw"This is a test" file.txt

The line "This is a test" is in the file, but it's not being deleted like it should be.

What I'm really trying to do is have it search for the line specified, and replace it with whatever. Can I do that with /write alone?

Thanks?


Experience The Void.. Are You Ready?
Re: /write stuff. #75502 16/03/04 07:14 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
Well, I just made a work-around using $read and $readn, but still, according to the help file I should be able to do what I want with /write alone..

So, am I just reading the help file wrong, or can you indeed do what I'm looking to? And if so..what am I doing wrong?

Thanks.


Experience The Void.. Are You Ready?
Re: /write stuff. #75503 16/03/04 08:13 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
Now there's a new problem..

I made this to work around the previous problem:

Code:
alias mp3r {
  if ($msn) {
    if (!$read(Mp3Rank.txt,nw,$+(*,$msn,*))) {
      write -n Mp3Rank.txt $msn : 1
      return $read(Mp3Rank.txt,w,$+(*,$msn,*))
    }
    write $+(-l,$readn) Mp3Rank.txt $msn : $calc($gettok($read(Mp3Rank.txt,n,$msn),2,58) + 1)
  }
}


Now..that will write to the file in this format:

Artist - Track : [number of times played]

And it works..until it gets four different lines in the file. Then, instead of making a new line, it appends to the last one. Anyone know what causes that, or yet ANOTHER thing I can do to work around this?



Experience The Void.. Are You Ready?
Re: /write stuff. #75504 16/03/04 09:19 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Well, /write -dw"match text" works just fine, but must be an exact match or a wildcard match, ie if there is a trailing space the line won't match that example, but would match -dw"match text*", or you could use the -r switch for a regex search.
Try /write -w"This is a test*" file.txt
To overwrite, you omit the d /write -w"This is a test*" file.txt Replacement text Again the exact match comes into it.

Re: /write stuff. #75505 16/03/04 09:48 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
I was using that earlier.
Code:
    write -w"$+($msn,*)" Mp3Rank.txt $msn : $calc($gettok($read(Mp3Rank.txt,n,$msn),2,58) + 1)


Doesn't work for me. Instead of replacing the string, it just appends to the end of it.

$msn = current song playing, in the format "Artist - Song : [num]"


Experience The Void.. Are You Ready?
Re: /write stuff. #75506 16/03/04 09:54 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
write -w"$+($msn,*)" <-is invalid, use $+(-w",$msn,*")

Re: /write stuff. #75507 16/03/04 09:59 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
Tried that after I saw what I posted, and it didn't work either.


Experience The Void.. Are You Ready?
Re: /write stuff. #75508 16/03/04 10:51 PM
Joined: Dec 2002
Posts: 111
F
Frog Offline OP
Vogon poet
OP Offline
Vogon poet
F
Joined: Dec 2002
Posts: 111
Nevermind, I got it.

The -n switch in the first /write was messing things up..

*Feels like a moron*


Experience The Void.. Are You Ready?