Harvester,
Of course you're getting those values back... And no, you don't need to clear a memblock before using it. The trouble is you see, memblocks are a
very low level access to the raw system memory, so you have to do a lot of the book keeping you'd normally expect the computer to do for you. Take for example, your situation;
WRITE MEMBLOCK WORD 1, 1, 1
WRITE MEMBLOCK WORD 1, 2, 2
WRITE MEMBLOCK WORD 1, 3, 3
WRITE MEMBLOCK WORD 1, 4, 4
WRITE MEMBLOCK WORD 1, 5, 5
WRITE MEMBLOCK WORD 1, 6, 6
These commands are "right and wrong" at the same time, in that they are correct in the way they are formatted but wrong in their use of the position values. Let's go on to the next protion of your code the reason;
FOR T=1 TO 6
PRINT MEMBLOCK WORD(1, T)
NEXT T
This code will
NEVER produce the results of the write commands up above, because the position value is incorrect in each instance save the first and last. (As was true of the write commands, but only the last was a correct location.) Here's why;
In a memblock, the array of RAM is dealt with as
BYTE VALUES for any addressing, then can be "fetched" or "written" as byte, word, or dword values. So, to write WORDS as you attempted the commands must be;
WRITE MEMBLOCK WORD 1, 1, 1
WRITE MEMBLOCK WORD 1, 3, 2
WRITE MEMBLOCK WORD 1, 5, 3
WRITE MEMBLOCK WORD 1, 7, 4
WRITE MEMBLOCK WORD 1, 9, 5
WRITE MEMBLOCK WORD 1, 11, 6
so we can read them back as;
FOR T=1 TO 13 step 2
PRINT MEMBLOCK WORD(1, T)
NEXT T
remember: byte counts for positions, then size of operation for read/write.
S.
Any truly great code should be indisguishable from magic.