accessing bytes in an array
StefanL38
Posts: 2,292
hello,
i would like to ask if there exists an easier way to access bytes within a bytearray
i would like to use the pointer to the array as a parameter of some methods
now my question is:
is there an easier way to access the bytes in the array than byte[noparse][[/noparse]p_ByteArrayPointer].... ?
This is an absolute adressing using the general command "byte". So if something is wrong about the pointer
it messes up HUB-RAM what do i know somewhere
what i don't want to do is call the method without a parameter by using the global variable
If i define all the arrays i need in order.
Will the adressrange of all arrays start at
@MyByteArray1
and end at
@MyByteArray8 + 20 ?
so that i could make a rangechecking of the pointer ?
best regards
Stefan
i would like to ask if there exists an easier way to access bytes within a bytearray
i would like to use the pointer to the array as a parameter of some methods
VAR byte MyByteArray1[noparse][[/noparse]20] byte MyByteArray2[noparse][[/noparse]20] PUB MyMethod(p_ByteArrayPointer) | index repeat index from 0 to 10 byte[noparse][[/noparse]p_ByteArrayPointer][noparse][[/noparse]index] := .....' that's the way i found out it works 'call of this method PUB someOtherMethod MyMethod(@MyByteArray2)
now my question is:
is there an easier way to access the bytes in the array than byte[noparse][[/noparse]p_ByteArrayPointer].... ?
This is an absolute adressing using the general command "byte". So if something is wrong about the pointer
it messes up HUB-RAM what do i know somewhere
what i don't want to do is call the method without a parameter by using the global variable
If i define all the arrays i need in order.
VAR byte MyByteArray1[noparse][[/noparse]20] byte MyByteArray2[noparse][[/noparse]20] byte ... byte MyByteArray8[noparse][[/noparse]20]
Will the adressrange of all arrays start at
@MyByteArray1
and end at
@MyByteArray8 + 20 ?
so that i could make a rangechecking of the pointer ?
best regards
Stefan
Comments
Yes, defined that way all bytes allocated will be contiguous. It's Array[noparse][[/noparse] size ], indexed 0..size-1, so the last byte used is actually at @MyByteArray8+19, you also want to ensure the pointer points no further than after the start of the last array though ...
-- if p_ByteArrayPointer => @MyByteArray1 and p_ByteArrayPointer =< @MyByteArray8
---- okay to use pointer
Post Edited (hippy) : 3/31/2008 1:12:38 AM GMT
thank you for the answer.
So i'm on the right way to do it
best reagrds
Stefan