mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I don't see how this is a feature suggestion, this is clearly a bug.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

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

Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
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.

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
That sounds about right.


Link Copied to Clipboard