mIRC Home    About    Download    Register    News    Help

Print Thread
#224503 12/08/10 10:27 AM
L
Lext01
Lext01
L
I'm having writing to files when using a variable for the line number in the /write command. For example:

write $writey

/writey return -dl $+ %rline

I have also tried using /write -dl $+ %rline on its own, but switched to the way above and it still doesn't work.

For some reason, the first example will work fine if I just type it in at the prompt, but if I try to run it through any kind of an alias, it doesn't work.

Any ideas?

#224508 12/08/10 12:07 PM
5
5618
5618
5
Looks to me like you're not specifying a file name.

#224509 12/08/10 12:29 PM
Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
Lext01, the identifier $readn is what you're looking for to return the line number you read.
Code:
alias example {
  var %rline = $readn
  if ($read(file.txt,w,$+(*,$$1-,*))) {
    write -dl $+ %rline file.txt
  }
}
This is just a rough example...

As 5618 said, you may have missed the text file name.

Tomao #224511 12/08/10 01:03 PM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
Uhm, I think you want to use $readn after the $read smile

Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
Horstl, it's a rough example but it works the way it is. :p

Tomao #224518 12/08/10 04:36 PM
Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Are you SURE it works? smile

$readn when used at the top like that will show the last line read BEFORE the alias was called. It won't give you the line number that you JUST read. Try it using different searches that return different line numbers and you'll see what we mean.

Anyhow, to the OP, /write should have -dl $+ $readn (or a variable or number) before the filename and the text being written. Putting anything between /write and -dl isn't going to work.

Joined: Jul 2007
Posts: 1,124
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,124
You're right, Riamus2. I tested it with one string in the text file. :P Thus I didn't realize it'd only delete it as the last line. Thanks for the heads up.

#224800 18/08/10 10:04 PM
Z
ziv
ziv
Z
I have encountered this problem long ago, and have always used the same solution since:

alias exe $1-

/exe write -dl $+ $readn filename text

Good luck,
ziv.


Link Copied to Clipboard