mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2018
Posts: 13
S
Seb Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: May 2018
Posts: 13
Code:
alias testcase {
  var %regex = /^$/
  echo -a -- $regex(%regex,$null) ; verify regex matches
  hadd -m testcase %regex 42
  echo -a -- $hfind(testcase,$null,0,R) ; <--- bug here; $hfind returns non-numeric value when it should return 1
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I'm guessing that $null is being treated as if a missing a required parameter, and is the same as $hfind(testcase,,0,R)

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
> $regex(%regex,$null)

Incorrect $regex() syntax. Try $regex($null,%regex)


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Confirmed on 7.52 non beta

Raccoon: the first $regex test is meant to show the attempt of $hfind(,,,R)'s function


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
It remains that the first $regex test is incorrect, and it incorrectly represents $hfind -R


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
How is it incorrect? It's unusual but it's to illustrate the report, it does ask if the regular expression "" matches the string "/^$/", which is what $hfind's R is doing


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
$hfind -R (reversed regex) is where regular expression patterns are stored in a hash table, and compared against the normal string passed in the $hfind parameter. $null is the normal string, not an 'unusual pattern'.

Just look at it. It's wrong, and you're wrong. :P

This isn't to say that $hfind() supports $null string parameters -- it doesn't -- but at least grasp the fundamentals of how mIRC works, Ouims!

$hfind() never works in any situation when $null is passed, whether -n -w -W -r -R are specified. This is a limitation of $hfind()

(The $regex qualitative test is still wrong.)


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
Uh well you're right that pattern don't become test string, I mixed things up here, but the usage of $regex is still valid/correct, (even if it's pointless), and the issue on $hfind does exist.

I disagree it's a limitation, $hfind should not be limited on the input it can receive, if $hfind were limited with the $null usage here, it wouldn't return incorrect value, it would return 0 instead of a possible positive integer

Last edited by Wims; 25/05/18 10:18 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
$hfind() gives no return value when '$null' is passed. This indicates that it does not work, as it does not work with many identifiers.

We would have a problem if $hfind() returned 0 or some other value that isn't nothing. Nothing means Error.

Should, or can, it be made to work? Sure, why not. I could see it useful in cases of $hfind(table,$null,0).data to discover table entries with null empty values. Or, whatever the original poster is trying to do as well.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Jul 2006
Posts: 4,180
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,180
This parameter is a string parameter, I can't think of any identifier which takes a string parameter which won't work with $null. This is not an error, $hfind should return 1 here.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2018
Posts: 13
S
Seb Offline OP
Pikka bird
OP Offline
Pikka bird
S
Joined: May 2018
Posts: 13
Yes, my bad, I meant to reverse the $regex parameters... Corrected testcase:

Code:
alias testcase {
  var %regex = /^$/
  echo -a -- $regex($null,%regex) ; verify regex matches
  hadd -m testcase %regex 42
  echo -a -- $hfind(testcase,$null,0,R) ; <--- bug here; $hfind returns non-numeric value when it should return 1
}

Joined: Dec 2002
Posts: 5,482
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,482
Thanks this issue has been fixed for the next version.


Link Copied to Clipboard