mIRC Home    About    Download    Register    News    Help

Print Thread
#266446 11/12/19 11:22 AM
Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
If removing the -t switch, it correctly returns null-length variable due to start position being beyond EOF. But with -t switch it gives:

* /bread: error allocating memory

I assume it's running out of memory trying to reach a condition that never happens

//bset &v 1 233 13 10 233 | bwrite -c test.dat 0 &v | bread -t test.dat 4 9 &v2 | echo -a result: $bvar(&v2) $bvar(&v2,0)

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Thanks for your bug report. The issue is due to a file read error due to the invalid parameters, not a memory error. This has been changed in the next beta to report a file error.

Joined: Jan 2004
Posts: 2,127
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Are you intending it to remain a halting error as it is now, or do like /bread does without the -t and fill the binvar with null?

Or like /fseek does where it reports the error message, but the script continues with file position set to the EOF and causes the next $fread as null? This is effectively what $read does, returning $null and setting $readn to $lines(file) + 1

//bset &v 1 233 13 10 233 | bwrite -c test.dat 0 &v | bread test.dat 4 9 &v2 | fclose test* | fopen test test.dat | fseek -l test 44 | echo 3 -a bread: $bvar(&v2) $bvar(&v2,0) read: $read(test.dat,nt,3) readn: $readn fopen.pos: $fopen(test).pos fseek: $fread(test)

Joined: Dec 2002
Posts: 5,411
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,411
Quote
Are you intending it to remain a halting error as it is now, or do like /bread does without the -t and fill the binvar with null?

Both /bread with and without -t will report errors if any of the Windows API calls they make return errors.

/bread without -t is a far simpler routine, so there is less chance of it returning errors.

/bread with -t is a more complicated routine that makes far more Windows API calls and, in this case, one of the calls returns an error.


Link Copied to Clipboard