Data in byte-sized vs. long-sized variables
coryco2
Posts: 107
Is it not possible to assign a value stored in a long-sized variable to a byte-sized variable, providing the value is no more than 255?
byteSizedVariable:= longSizedVariable
For some reason it doesn't seem to work that way. I then tried
byteSizedVariable:= longSizedVariable.byte[0]
to assign the least significant byte of the long value, but no go.
What am I missing here?
byteSizedVariable:= longSizedVariable
For some reason it doesn't seem to work that way. I then tried
byteSizedVariable:= longSizedVariable.byte[0]
to assign the least significant byte of the long value, but no go.
What am I missing here?
Comments
This does work as does
byteSizedVariable := longSizedVariable.byte[ 0 ]
The "no go" must be due to something else that we can't tell with the amount of information given. Maybe you misspelled the variable name?
It appears that I am running into my trouble writing bytes to a DAT data table. Is there a difference between
byte[@dataTable1][0] := "0"
and
byte[@dataTable1][0] := 0
as far as the value that is written to byte in dataTable?
byte[@dataTable1][0] := "0"+ Variable1
will just add the ASCII value of character 0 to the numeric value of Variable1? And what will the result be in the table? A number or a character string?
LocalRoger just posted an object which also does these things.
Make sure you get what's going on straight in your head. It took me a while to make sense of ASCII characters verses the values used by the Prop internally. I see a lot of forum members have trouble with this and there has been a lot of discussion on this issue. I'll try to find some links to past threads and post them here.
http://forums.parallax.com/showthread.php/149189-UPDATED-with-example-Modular-Programming-in-Spin