mIRC Home    About    Download    Register    News    Help

Topic Options
#265044 - 20/02/19 08:27 PM .pos property $regml() $regmlex() unicode
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1109
I'm helping rockcavera who first noticed parts of this.

The .pos property for $regml() and $regmlex() are not reporting the correct position when the string contains codepoints above 127.

Code:
//var %msg multibyte character $chr(233) test | echo -a pos: $pos(%msg,test) | noop $regex(%msg,/(test)/u) | echo -a regex: $regml(1).pos


In 7.52 and earlier

returns whether or not /u modifier is used:
pos: 23
regex: 23

In 7.53 and newer

returns whether or not /u modifier is used:
pos: 23
regex: 24

I then checked to see if $regmlex().pos did the same thing, and it does the same as $regml() in both versions. However at first I was having trouble avoiding an error message until discovering that $regmlex() wasn't working without using the <name> parameter even though /help indicates that [name] is optional.

Top
#265057 - 22/02/19 11:37 AM Re: .pos property $regml() $regmlex() unicode [Re: maroon]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4379
Loc: London, UK
Thanks, this issue has been fixed for the next version.

Top
#265128 - 11/03/19 05:15 PM Re: .pos property $regml() $regmlex() unicode [Re: Khaled]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1109
Looks like the beta fixes the .pos issue in $regml and $remlex. Can you confirm if $regmlex is supposed to require the 'name' parameter instead of being optional as /help says? It's saying invalid parameter until I use the name:

Code:
//var %msg multibyte character $chr(233) test | echo -a pos: $pos(%msg,test) | noop $regex(%msg,/(test)/u) | echo -a regex: $regmlex(default,1).pos


Top
#265131 - 11/03/19 06:16 PM Re: .pos property $regml() $regmlex() unicode [Re: maroon]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4379
Loc: London, UK
Yes, it needs it. $regmlex() has three parameters, two of which are optional, the first and the last. If you only use two parameters, it cannot know which two you've specified.

Top
#265133 - 11/03/19 06:49 PM Re: .pos property $regml() $regmlex() unicode [Re: Khaled]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3475
Loc: France
That's not correct.

Code:
//noop $regex(abcdefgh,/([a-h])([a-h])/g) | echo -a $regmlex(1,2) $regmlex(2,2)
$regmlex uses the first parameter as the Nth match, which is correct for regex-identifier behaviors. $regmlex is working correctly, it's the first parameter that is optional, the name; the others two are required, you want to access the Nth match and Mth capture for that match.

Edit: seems like the others two are not really required, not a huge fan of the design but if $regmlex(name,N) works, then $regmlex(N) should work the same when applicable


Edited by Wims (11/03/19 09:15 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#265134 - 11/03/19 07:06 PM Re: .pos property $regml() $regmlex() unicode [Re: Khaled]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 1109
But my example did use 2 parameters, and $regmlex did know which to use. If only 1 parameter is required, then why did $regmlex(1) fail while $regmlex(default,1) succeeded?

edit: in other words,

$regmlex(default,1).pos works,
$regmlex(default,1,1).pos works

but $regmlex(1).pos using the only parameter that's not optional is failing


Edited by maroon (11/03/19 07:19 PM)

Top
#265141 - 12/03/19 09:48 AM Re: .pos property $regml() $regmlex() unicode [Re: maroon]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4379
Loc: London, UK
That is because the identifier is trying to guess which parameters you have specified based on their content. You should always specify the name.

Scripters have often requested that some identifier parameters be optional for the sake of convenience, ie. to decrease typing, make scripts shorter, etc. Unfortunately, the side-effect is that quite a few identifers that support optional parameters have to guess which parameter you've specified based on content. It also makes them more difficult to extend or update. It's not good design and if I could do it without breaking scripts, I would remove optional parameters in many identifiers.

Please note that I will not change how this feature works. It has worked like this for far too long and changing it now could easily break older scipts.

Top