mIRC Home    About    Download    Register    News    Help

Print Thread
$read(file,r,regex) ?? #137494 13/12/05 11:47 AM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
Hello.
how can i read all the lines in a file using $read's regexmatch??

alias tr { .fopen -o tr test.txt | .fwrite -n tr * test1 | .fwrite -n tr * test2 | .fwrite -n tr * test3 | .fclose tr }
//echo -a $read(test.txt,r,.+)
* test1

confused

Re: $read(file,r,regex) ?? #137495 13/12/05 11:51 AM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
If you need to read every line in a file then just loop through the file with $fread:

Code:
alias tr {
  .fopen -no tr test.txt
  if (!$ferr) {
    .fwrite -n tr * test1
    .fwrite -n tr * test2
    .fwrite -n tr * test3
    [color:red]while (!$feof) echo -s $fread(tr)[/color]
    .fclose tr
  }
}


The red part is the code that dumps the file to your status window.

Re: $read(file,r,regex) ?? #137496 13/12/05 12:05 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You can also use /filter with the g flag.


Gone.
Re: $read(file,r,regex) ?? #137497 13/12/05 12:34 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
sorry but no one understood me. crazy

i want to use match multi-lines.

alias tr { .fopen -o tr test.txt | .fwrite -n tr * test1 | .fwrite -n tr * test2 | .fwrite -n tr * test3 | .fclose tr }
this is for example. if i have a file contain those lines

Re: $read(file,r,regex) ?? #137498 13/12/05 12:38 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well you didn't really explain anything did you? How do you expect to be helped if you cannot even explain in proper English what you want to do exactly. (i want to use match multi-lines. <-- what kind of mambo jambo is this?)

Your code that you posted doesn't help with anything really, it just writes a few lines of text to a file. Your second post contains the exact same code but in bold, :rolleyes: as if putting it in bold is going to explain it better.

Why don't you explain with an actual example (not in coding but in words) what you want to do exactly, starting with a file that has a few lines of text, and what exactly you want to get from that file.

Going by your $read(file,r,.+) you just want to return 1 non-blank line from the text file, which you don't need a regex for by the way.


Gone.
Re: $read(file,r,regex) ?? #137499 13/12/05 12:39 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
oh btw i know how to do it using /filter but i want to know how to match multi-line using $read,r

Re: $read(file,r,regex) ?? #137500 13/12/05 01:07 PM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
sorry for my english FOP. i'll explain it from the end.
.+ this expression matches everything. ok??
try this. //echo -a $read(readme.txt,r,.+)
what well happens? u'll get the first line of the readme file which is it.
mIRC(R) v6.16 Internet Relay Chat Client
i want to match multi-line. sooo. when i use //echo -a $read(readme.txt,r,.+) all the lines in the readme.txt file will be echo-ed in the active window.

mIRC(R) v6.16 Internet Relay Chat Client
Copyright (c) 1995-2004 mIRC Co. Ltd.
All Rights Reserved.

Welcome to mIRC, an Internet Relay Chat client.

mIRC attempts to provide a user-friendly interface for use with
the Internet Relay Chat network. The IRC network is a virtual
meeting place where people from all over the world can meet and
talk.

To IRC all you need to do is Connect to a server, Join a channel,
and Chat!

'til the EOF.


got it fop?? crazy

Re: $read(file,r,regex) ?? #137501 13/12/05 01:58 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
You can't. That's not what the r flag is for.
Again though, if you just want to output the entire file just loop through it, there's no need for a regular expression.

Re: $read(file,r,regex) ?? #137502 13/12/05 01:58 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
$read returns a single line, not multiple lines.

What is preventing you from looping through the file, or using /filter with g flag like I already suggested?

You're asking for stuff that doesn't exist, while there are enough tools to do what you want already.

alias showfilter echo -a > $1
//filter -fkg <file> showfilter <regex>

You don't need a regex if all you want to do is show the contents of a file to your active window, you can simply use loadbuf:

alias showfile loadbuf $iif($active != status window,-pi $ifmatch,-spi) $$1-


Gone.
Re: $read(file,r,regex) ?? #137503 14/12/05 08:09 AM
Joined: Jul 2005
Posts: 56
W
whoami Offline OP
Babel fish
OP Offline
Babel fish
W
Joined: Jul 2005
Posts: 56
well... am sorry and thank u all for your help