Bug #847
closedBSave is saving one less byte than it should. Also, the example shown on the F5 help is wrong.
0%
Description
Tested in 1.0.0 (B10) u16 (Oct 9)
In Bsave we have successfully reproduced one of the ERRORS in AMOS.
Perhaps in a STRICT AMOS mode we could do it this way, but in AOZ this should NOT happen.
It is wrong!
Example:
Palette 0,$FFFFFF,$FF3333
Pen 1 : Paper 0 : Curs Off : Cls 0
'
' Reserving 10 bytes.
'
Print "Reserve & fill a 10-byte buffer:"
Reserve As Work 15,10
addrStart = Start(15)
addrEnd = addrStart+9 ' Total of 10 bytes
Print "Length(15):";Length(15)
' Poke in the numbers 1 - 10 in those 10 bytes.
For i=0 To 9
Poke addrStart+i,i+1
Next i
' Verify the contents
For i=0 To 9
Print Right$(Hex$(Peek(addrStart+i),2),2);" ";
Next i
Print
Print "press any key"
Wait Key
' BSave the file.
fName$="application:TestBsave.dat"
Print
Print "BSave ";fName$
' Although addrStart and addrEnd are correct, only 9 bytes are written.
Print "addrStart:";addrStart,"addrEnd:";addrEnd
Print "(Total of 10 bytes)"
Bsave fName$,addrStart To addrEnd
Pen 2
Print "Length of saved file:";File Length(fName$)
Pen 1
Print
Print "press any key"
Wait Key
' Clear buffer
Print
Print "Buffer cleared:"
For i=0 To 9
Poke addrStart+i,0
Next i
' Yes, it's clear.
For i=0 To 9
Print Right$(Hex$(Peek(addrStart+i),2),2);" ";
Next i
Print
Print
Print "press any key"
Wait Key
Print
Print "Bload saved file ";fName$
' Bload & Verify the contents
Bload fName$,addrStart
For i=0 To 9
If Peek(addrStart+i) <1 Then Pen 2
Print Right$(Hex$(Peek(addrStart+i),2),2);" ";
Next i
Pen 1
' NOTE: Last byte of buffer was not Bloaded.
Print
Print "Verified the last byte was not saved."
Print "press any key"
Wait Key
The help on both F5 and F6 is also wrong.
It was taken from the INCORRECT example in the AMOS Pro manual... page 05.09.05
// Start Example Code
Bsave "Test",Start(5) To Start(5)+Length(5) : Rem Save memory bank 5
// End Example Code
The above example should fail! It goes 1 past the end of the buffer.
For example: If Start(5) was 0, and the Length(5) was 8
It should save from 0 to 7 (a total of 8 bytes).
If we save from Start(5) to Start(5) + Length(5), thats 0 to 8 (a total of 9 bytes). ERROR!
Updated by David Baldwin about 3 years ago
- Status changed from New to Resolved
- Assignee set to David Baldwin
Fixed. Same old problem when length is calculated from 'End' - 'Start'. 9 - 0 = 9, not 10
Also fixed Bsave "filename", start, length which gave internal error.
Updated by Brian Flanagan about 3 years ago
- Status changed from Resolved to Closed
Verified - Working! :-)
Thanks Dave!