mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
hi again i need to read and write a file..

but i ever receive only one line of the file

what i need

is to write (append) a line to the file
delete a certain line
and read all lines and checke them in a while / if

can someone help me with the reading and writing syntax??

or is there may a way to send and read from a file located on a server maybe with sendings vars to a php ( php sided would be no problem for me)

greetz

EDIT: b4 i need to make one ,more thread annother question also...
how do i define a functin that receives a string as data and how do i call it

Last edited by javatis; 13/07/05 02:23 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Write (append) text:
//write filename.txt This is a line of text.

Delete a line number:
//write -dl1 filename.txt

Read the entire file:
Code:
set %counter 1
while (%counter <= $lines(filename.txt)) {
  echo -a $read(filename.txt,%counter)
  inc %counter
}


**Place this code inside some event... on text or on input or in an alias, or wherever you want to use it from.

For the above code, just replace the echo -a command with your if/while statement that you mentioned wanting to use. It will read one line at a time and you'll need to look at each line as it is read.

To store a string to a variable:
//set %myvariable This is a string

Or, for a temporary variable:
//var %myvariable This is a string

As far as the PHP thing, you need to look into using Sockets.


Invision Support
#Invision on irc.irchighway.net
Joined: Aug 2004
Posts: 43
J
javatis Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Aug 2004
Posts: 43
works fine but with the the deleting...

/write -dl %MyVar filename.txt

^^ whats wrong with this

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Quote:

works fine but with the the deleting...
/write -dl %MyVar filename.txt

you have to "join" the number to the -dl switch
/write -dl $+ %MyVar filename.txt

Joined: Feb 2005
Posts: 15
X
Pikka bird
Offline
Pikka bird
X
Joined: Feb 2005
Posts: 15
/write $+(-dl,%MyVar) filename.txt

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
$+(,) 5 characters
$+ 2 characters
both work

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
$+ is 4 characters, the 2 spaces around them are required
With the same logic $+(,) is 6 (or 7), but it gets better when joining more than 2 parts together...

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
If you did it from Status Window or from a channel or query or something, it's
//write -dl %MyVar filename.txt
The // is needed to tell mIRC to check for $identifiers and %vars and to evaluate them, with / they are just passed as text.

If it is part of a script (ie written in remotes (alt-r alt-r) section or aliases (alt-r alt-a) section) then you don't need the / anyway, since each line is supposed to start with a command. If it doesn't work then, you probably have an error somewhere else, best to echo -s myvar %MyVar before and check if that value is correct.

Although the help file says it's write -dlN, write -dl N works too without the need for $+


Link Copied to Clipboard