mIRC Homepage
Posted By: whoami $read(file,r,regex) ?? - 13/12/05 11:47 AM
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
Posted By: hixxy Re: $read(file,r,regex) ?? - 13/12/05 11:51 AM
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.
Posted By: FiberOPtics Re: $read(file,r,regex) ?? - 13/12/05 12:05 PM
You can also use /filter with the g flag.
Posted By: whoami Re: $read(file,r,regex) ?? - 13/12/05 12:34 PM
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
Posted By: FiberOPtics Re: $read(file,r,regex) ?? - 13/12/05 12:38 PM
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.
Posted By: whoami Re: $read(file,r,regex) ?? - 13/12/05 12:39 PM
oh btw i know how to do it using /filter but i want to know how to match multi-line using $read,r
Posted By: whoami Re: $read(file,r,regex) ?? - 13/12/05 01:07 PM
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
Posted By: hixxy Re: $read(file,r,regex) ?? - 13/12/05 01:58 PM
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.
Posted By: FiberOPtics Re: $read(file,r,regex) ?? - 13/12/05 01:58 PM
$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-
Posted By: whoami Re: $read(file,r,regex) ?? - 14/12/05 08:09 AM
well... am sorry and thank u all for your help
© mIRC Discussion Forums