There is a data construct called a union in the 'c' programming language. This construct allows for several variables types to be overlaid at the same memory address. This is very useful for decoding bits out of a word. The S7 system has a equivalent way of achieving the same result using the AT construct thus:-
wData : WORD;
bData AT wData : STRUCT
Bit0:BOOL;
Bit1:BOOL;
Bit2:BOOL;
Bit3:BOOL;
Bit4:BOOL;
Bit5:BOOL;
Bit6:BOOL;
Bit7:BOOL;
Bit8:BOOL;
Bit9:BOOL;
Bit10:BOOL;
Bit11:BOOL;
Bit12:BOOL;
Bit13:BOOL;
Bit14:BOOL;
Bit15:BOOL;
END_STRUCT;
Is there anything similar in CLX ST?
I realise I could achieve the same with masks and shifts or by copying the word data to another structure. However the form requires a lot more code and the latter requires more memory usage. I would looking for a direct equivalent if there is one.
Any ideas anyone?
wData : WORD;
bData AT wData : STRUCT
Bit0:BOOL;
Bit1:BOOL;
Bit2:BOOL;
Bit3:BOOL;
Bit4:BOOL;
Bit5:BOOL;
Bit6:BOOL;
Bit7:BOOL;
Bit8:BOOL;
Bit9:BOOL;
Bit10:BOOL;
Bit11:BOOL;
Bit12:BOOL;
Bit13:BOOL;
Bit14:BOOL;
Bit15:BOOL;
END_STRUCT;
Is there anything similar in CLX ST?
I realise I could achieve the same with masks and shifts or by copying the word data to another structure. However the form requires a lot more code and the latter requires more memory usage. I would looking for a direct equivalent if there is one.
Any ideas anyone?