Firstly, I hope you're not trying to insert hex data when you do
MyVar = FFEEDDCCBBAA, because that's the wrong way. When you assign a string to a variable, you are inserting an array of ascii-codes (each of which fills one byte).
Consider this code:
Code:
SetFormat, IntegerFast, hex
VarSetCapacity (Myvar,20,0)
MyVar = FFEEDDCCBBAA
; if MyVar is an array of 3-byte members, then this is the hex data in MyVar:
; offset hex value
; 0 0x464645
; 3 0x454444
; 6 0x434342
; 9 0x424141
A := numget(MyVar,0, "UInt") & 0xFFFFFF ; using & 0xFFFFFF truncates the highest-
B := numget(MyVar,3, "UInt") & 0xFFFFFF ; order byte in the 4-byte 'UInt'
C := numget(MyVar,6, "UInt") & 0xFFFFFF
D := numget(MyVar,9, "UInt") & 0xFFFFFF
msgbox, %MyVar%
E := A * 2
ListVars
msgbox %E%
Notice that, although the variables appear to receive the expected bytes, their
order is reversed. This is because the 'UInt' data type, which has a size of 4 bytes, uses the
leftmost byte as its
low order byte.
So, you're left with two options to retrieve a 3-byte struct from a variable: either grab 4 bytes, truncate the last one, then swap bytes 1 and 3, OR take the sum of 3 sequential bytes
bitshifted to match their order ( Ch1 << 16 | Ch2 << 8 | Ch3 << 0 ).