mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
Code:
; file.txt contains several lines, one of them is "Blah the universe"

var %Bl = Blah the universe
echo -a BZZ $read(file.txt,npts,%Bl)
echo -a BZZ $readn


The script returns:
BZZ
BZZ 3
(that's an example, i don't paste all my code here)

How's that possible?! Why "Blah the universe" doesn't show up after "BZZ"?! How do i fix this?


-= endless in a victory of a yourself =-
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
When you use the 's' flag $read will return the text after the part you scanned the file for, so in this case it looks for data after "Blah the universe" and there isn't any.

If you change the search to Blah it should return BZZ the universe.


New username: hixxy
Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
How do i make it return the whole line? Different keys maybe?

I don't want to make an extra $read just to get what it already reads but can't display..

PS Thanks so much!

Last edited by MauS; 25/06/05 10:38 PM.

-= endless in a victory of a yourself =-
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
To return the whole line you could substitute the s flag for the w flag and use Blah * as the text to search for.


New username: hixxy
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well you already know what the start of the line looks like because you just inputted it to $read() to search for it.

Code:
; file.txt contains several lines, one of them is "Blah the universe"

var %Bl = Blah the universe
echo -a BZZ [color:red]%B1[/color] $read(file.txt,npts,%Bl)
echo -a BZZ $readn


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: May 2003
Posts: 78
M
MauS Offline OP
Babel fish
OP Offline
Babel fish
M
Joined: May 2003
Posts: 78
Well... I needed an EXACT match, not partial match. So my idea was to compare %B1 and the whole line to verify whether the match is exact or not. If not, it is skipped.

To check it now i use "if (!$read(...))" -- as long as the match is exact, %B1 will be equal to the whole line, and $read will be empty. It even works smile

But... Is there a simplier and a more correct way? For instance, a key param for $read to make it search only for exact matches would be great...

Exact match... i mean that search for "Blah" should return only line "Blah", but not line "Blah the universe".


Quote:
Tidy Trax:
To return the whole line you could substitute the s flag for the w flag and use Blah * as the text to search for.
I can't do than 'cause i only know the whole line to search for and i need an EXACT match.


-= endless in a victory of a yourself =-
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
To check it now i use "if (!$read(...))" -- as long as the match is exact, %B1 will be equal to the whole line, and $read will be empty. It even works smile


That well think its found a match if it cant find a match as well

searhing for "asldjkaslkdjaskldjasldjalsdjasdjakld" no match is fouind so $read has nothing in it

I think this should work
if (!$read(.....) && $readln) { .... matched ... }

!$read well be true if not matched or exact match
but
$readln is the line number matched, if there isnt one then its zero so it fails


Link Copied to Clipboard