mIRC Home    About    Download    Register    News    Help

Print Thread
Writing to files. #224503 12/08/10 10:27 AM
Joined: Aug 2010
Posts: 1
L
Lext01 Offline OP
Mostly harmless
OP Offline
Mostly harmless
L
Joined: Aug 2010
Posts: 1
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?

Re: Writing to files. [Re: Lext01] #224508 12/08/10 12:07 PM
Joined: Jun 2007
Posts: 933
5
5618 Offline
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Looks to me like you're not specifying a file name.

Re: Writing to files. [Re: Lext01] #224509 12/08/10 12:29 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: Writing to files. [Re: Tomao] #224511 12/08/10 01:03 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Uhm, I think you want to use $readn after the $read smile

Re: Writing to files. [Re: Horstl] #224516 12/08/10 04:12 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Horstl, it's a rough example but it works the way it is. :p

Re: Writing to files. [Re: Tomao] #224518 12/08/10 04:36 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
Re: Writing to files. [Re: Riamus2] #224526 12/08/10 08:40 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
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.

Re: Writing to files. [Re: Lext01] #224800 18/08/10 10:04 PM
Joined: Sep 2009
Posts: 52
Z
ziv Offline
Babel fish
Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
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.