How to copy a buffer in spin
I have a need to copy a buffer from a spin object. This buffer is in the VAR section of the object I'm consuming.
My first thought was something like this:
The line @dest := @source + index doesn't compile, and I understand why. I guess my question is, is it possible to increment and address passed into a subroutine and how do I reference it as a destination?
TIA
My first thought was something like this:
VAR
byte source[noparse][[/noparse]32]
PUB ReadBuffer
' do something with source buffer
PUB CopyBuffer(bufferAddress, sizeAddress) | size, dest, index
size := long[noparse][[/noparse]size]
' what to do with dest here?
'dest := long[noparse][[/noparse]bufferAddress]
repeat index from 0 to size
' again, don't know how to set the destination buffer
' @dest := @source + index
' I think this is the right thing to do in order to increment my destination pointer
dest := @dest + 1
The line @dest := @source + index doesn't compile, and I understand why. I guess my question is, is it possible to increment and address passed into a subroutine and how do I reference it as a destination?
TIA

Comments
Here is the code that works:
PUB CopyBuffer(bufferAddress, size) | dest, index dest := byte[noparse][[/noparse]bufferAddress] repeat Index from 0 to size - 1 dest := @buf + index dest := byte[noparse][[/noparse]@dest + 1]Edited to fix the off by one error.
Post Edited (soshimo) : 7/15/2010 7:11:09 PM GMT
-Phil
I want to copy a buffer from an object. This pub will expose that functionality for me. I will call it like so:
I'm hoping that will do it for me.
Thanks for the help.
Post Edited (soshimo) : 7/15/2010 9:33:00 PM GMT