- May
- 13,190
- 180
This BTM will copy a file.
If I change nReadSize to 2046 (and use a file bigger than that) it fails as follows.
The DO loop never terminates. And, each time through the DO loop what's written to the output file is: the first 2046 bytes of the input file followed by 0x40 0xFF.
What's happening? [It's a counted DO loop so I can't understand how it could fail to terminate regardless of whether the file read/writes are correct.]
Code:
setlocal
set nReadSize=2045
set nReads=%@eval[ceil(%@filesize[%1]/%nReadSize)]
set hIn=%@fileopen[%1,r,b]
set hOut=%@fileopen[%2,w,b]
on break goto close
do i=1 to %nReads
set junk=%@filewriteb[%hOut,-1,%@filereadb[%hIn,%nReadSize,x]]
enddo
:close
set junk=%@fileclose[%hOut]
set junk=%@fileclose[%hIn]
If I change nReadSize to 2046 (and use a file bigger than that) it fails as follows.
The DO loop never terminates. And, each time through the DO loop what's written to the output file is: the first 2046 bytes of the input file followed by 0x40 0xFF.
What's happening? [It's a counted DO loop so I can't understand how it could fail to terminate regardless of whether the file read/writes are correct.]