mIRC Home    About    Download    Register    News    Help

Topic Options
#264170 - 06/11/18 06:40 AM $cb(N,,&var) can exclude data
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 969
It appears this is by design, where $cb(N,,&binvar) loads the &binvar with identical content to that received from $cb(N). It looks like the clipboard tokenizes line numbers by the $lf, but then fills $cb(N) by tokenizing that token by the $cr. Normally, this results in the line that everyone wants, where the $crlf or $lf is excluded. However if there are any bytes between the $cr and the $lf, they don't get included in $cb(N) nor in $cb(N,,&binvar). In this example, the foo doesn't go into the clipboard except if accessing the entire clipboard as line -1.

Code:
//clipboard line1 $cr foo $lf line2 | var -s %i $cb(0) | while (%i > -2) { noop $cb(%i,,&var) | echo -a line %i = $bvar(&var,1-) $bvar(&var,1-).text vs $cb(%i) | dec %i }

//clipboard line 1 $cr secret hiden from $ $+ cb(1) and $ $+ cb(2) $lf line 2 | echo -a $cb(1) $cb(2)



Perhaps another switch for the 2nd parameter, at least for the &binvar output, which avoids line-1 through line-last excluding all data between the $cr and $lf, as well as making it easier to find out whether then Nth line ended with $crlf or just $lf.

Something like $cb(N>=0,n,&binvar) could include all data through the $lf or end-of-clipboard.

Also bumping the support for loading binvar into clipboard like /clipboard -b &binvar

Top
#264173 - 06/11/18 01:19 PM Re: $cb(N,,&var) can exclude data [Re: maroon]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3438
Loc: France
I don't see how this is a feature suggestion, this is clearly a bug.
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#264174 - 06/11/18 05:19 PM Re: $cb(N,,&var) can exclude data [Re: Wims]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 969
I don't really think it's not-a-bug either, but it's the kind of bug that would break compatibility if $cb(N,,&var) started including $cr and $lf in the string by default, or $cb suddenly started working "correctly".

So the happy medium to get the correct behavior using a new switch that includes the missing data between a $cr and $lf. Whether there needs to be a -n0 or -n1 to have different flavors of this, i dunno. Such as whether or not to include the trailing $lf, and if not - whether to include 1-or-more $cr's touching the $lf, how to handle lone $cr's within the line, how to handle $lfcr etc.

But I don't think there was ever the intent to discard all bytes between a $lf and a $cr not touching it.

And I wasn't precisely correct when I mentioned that the line numbers were tokenized by $lf, because it doesn't behave like $gettok where leading/trailing/duplicate-consecutive $lf delimiters are ignored.

Top
#264253 - 12/11/18 09:36 AM Re: $cb(N,,&var) can exclude data [Re: maroon]
Khaled Offline


Planetary brain

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

Top
#264342 - 22/11/18 08:24 AM Re: $cb(N,,&var) can exclude data [Re: Khaled]
maroon Offline
Hoopy frood

Registered: 12/01/04
Posts: 969
Something I hadn't thought to test before was how $cb(0) counted lines vs how $lines(file) counted them. It looks like the fix now makes the clipboard and diskfile lines always be matching numbers.

Code:
//clipboard $cr $+ 1 $+ $lf $+ 2 $+ $crlf $+ 3 $+ $cr $+ $crlf $+ 4 $+ $crlf $+ $lf $+ 5 $+ $lf $+ $cr $+ 6 $+ $cr $+ 7 | noop $regsubex(foo,$cb,,,&var) | bwrite -c test.dat 0 -1 &var | var %i $lines(test.dat) | echo -a cb(0) $cb(0) vs lines(test.dat) %i | while (%i) { noop $cb(%i,,&v2) | echo -a %i : $bvar(&v2,1-) : $bvar(&v2,1-).text vs $read(test.dat,nt,%i) | dec %i }



Prior to this change, 7.52-nobeta thought $cb(0) was 7 and $lines(test.dat) was 11, but now they both think there are 11 lines. Somewhere between 7.52 and 6.35 $lines began counting disk lines differently, as 6.35 thinks both the clipboard and diskfile had 7 lines.

It looks like every $cr and $lf are now counted as another line ending, except for the $cr immediately preceding the $lf causing it to be handled as part of $crlf. [end-of-file] is also counted as an additional line-ending if the file doesn't end with a $cr or $lf. Even a backwards $lfcr is counted as 2 lines.

Top
#264343 - 22/11/18 09:03 AM Re: $cb(N,,&var) can exclude data [Re: maroon]
Khaled Offline


Planetary brain

Registered: 04/12/02
Posts: 4297
Loc: London, UK
That sounds about right.

Top