Setting a byte array of 4 to the value of a long
Zap-o
Posts: 452
I don't know if this is possible to do but, I wish to set a byte array value to a variable that is a long.
Any ideas?
var byte rxdata [ 4 ] long Qualifier Pub main Bytemove(@rxdata,@Qualifier,4)
Any ideas?
Comments
Of course that assumes that the bytes come out in the right order for your application. If not you have more work to do.
*edited - solved
Thanks a million
Sorry As I say it -- It is for have nice help for other Beginners.
If You else other on write "SOLVED" ---> write even HOW it is solved even if that code are not NICE ---> it give other Beginners possibility how them need handle IT.
I solved this problem by simply using the command that Heater mentioned. And as my 2nd post mentioned another issue was created because my bytes were backwards in the rxdata array.
original What I did not mention was that Qualifier := $48454C50 'HELP
Solution
And I changed Qualifier := 504C4548 'PLEH
THANKS for understanding.
Example:
This way there isn't any conversion overhead. 'rxdata's BYTEs are aliased into 'Qualifier's LONG and vise versa.
This method also uses half the nember of LONG variables
Why? Because it assumes that rxdata[0] is long-aligned, which may not always be the case. And, if it's not, the assignment will not work the way you want it to.
-Phil