setting a range of variables
AGCB
Posts: 327
in Propeller 1
Will this set a range of bytes
Thanks
Aaron
VAR byte flags[7] PRI SetFlags 'set flags according to key press IF din[0] == $01 flags[0] := 1 '1st byte = 1 flags[7-1] := 0 'all other bytes = 0 CON 'Will this set a range of bytes? Or is there a different way? ( .. ) didn't work
Thanks
Aaron
Comments
I just thought there might be an easier way. I might have to read up on CASE also
Aaron
...will set bits 4 and 1 while clearing the others. Two flags set; six flags cleared; one line of code.
The bytefill() instruction does set one or many bytes in a single instruction, but they must be the same value.
They only need to be 1 or 0 so that will work fine. I'll experiment with it early tomorrow morning.
Thanks
Aaron
Something that I suggest you do to make your code more readable is to create CON masks for your flags.
This allows you code to make more sense -- when you do things like this
My point is to be careful using "magic numbers" like I did in my example above. You can still set/clear multiple flags with one line, and make it readable:
You can test with a named flag easily, too: