mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2006
Posts: 182
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 182
//echo -a $read(versions.txt,s,Change)

This seem not to work. As far as I can tell, the rest of the options for $read work just fine.

Yes, versions.txt exists. Yes, it should find Change (its the 3rd or 4th line). Anyone who has Mirc 6.3 should have this file in their Mirc directory.

Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
Confirmed. mIRC 6.3, Windows XP

Actual test using the provided parameters came back with an error, as it should, as the search parameter Changes, should have a : on the end of it, to match the entry on line 3 of versions.txt

Even with the : appended, to match the line, the command still returns Insufficient Parameters.

Joined: Dec 2002
Posts: 2,884
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,884
There are a bunch of things here that are probably causing that "Insufficient parameters" error, none of them are bugs though.

1. In mIRC 6.3 installations, versions.txt is no longer in $mircdir (unless you've upgraded an older version without changing it or explicitly made mIRC use the installation directory). This means that there's no file for $read() to search and therefore you'll get the error. To be sure this isn't the problem, you should be using $read($+($nofile($mircexe), versions.txt), s, Changes).

2. The search algorithm used by the s switch matches from the start of the line only, and matches on whole words only, meaning that it will not match "Changes" because there is no line in versions.txt that contains only the word "Changes" or "Changes" followed immediately by whitepace. As RusselB said, you should be matching against "Changes:" if you want to match the third line in the current versions.txt, so the code should now be changed to $read($+($nofile($mircexe), versions.txt), s, Changes:).

3. When using the s switch, $read() returns the remainder of the line. That is, it only returns the part of the line after the search text. There is no line in versions.txt that starts with the word "Changes:" (or "Changes") that has any text following it. Since there's no text following it, $read() will return nothing. This is true any time that you use $read() with the s switch and the search text is an exact match for the whole line. So how do you know when it's matched? Using $readn. So now, if we update the code one more time, we get this:
//echo -a $read($+($nofile($mircexe), versions.txt), s, Changes:) (line number: $readn $+ )
And the result:
(line number: 3)

Voila! It works fine. The moral of the story is that when using the s switch with $read(), you should always use $readn to check if it has been successful.

Believe me, I realise the s switch is confusing - especially since it's very different to how the w switch works - but it's no bug.

Joined: Aug 2004
Posts: 7,168
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,168
Points 1 & 2 I had accounted for (as you noted in point 2), but I forgot about your 3rd point.

Further testing shows that the s switch for $read is working properly.

Joined: Aug 2006
Posts: 182
T
Thrull Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Aug 2006
Posts: 182
I see. Thanks very much for explaining it. I hadn't used it before and someone else pointed it out to me. Upon testing, it seemed broken.

I'd suggest that the help file be updated to accurately reflect how the s option works. Knowing how it works now and re-reading the help file leads to me think its a bit ambiguous.

Thanks again. smile

Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641


Link Copied to Clipboard