The following syntax can be used to access the single bits of a variable (for those that provide for it):
Syntax |
<variable>.<bit> <variable>.(<expression>) |
---|---|
<variable> |
Desired variable |
<bit> |
Number of bits (#1) |
<expression> |
Generic expression R3 for calculation number of bits (#1) |
(#1) the maximum number depends on the type of variable (e.g., 31 for U32).
From RC3E v.33-01-21 it is possible to access the bit indicated by exp, in round brackets, just as it is accessed from Ladder language. Compatibility with the old syntax is maintained:
<variabile>.<varix> |
Translated as <variable>.(<varix>) but with generation of a warning that it should no longer be used. There may in fact be problems with the debugger |
Examples
; definition of accessory variables INT pippo INT pippo
; I reset the value of "pippo" to zero pippo = 0 ; I set the first bit of pippo to "1" pippo.0 = 1 ; I set the third bit of pippo to "1" pippo.2 = 1 ; now "pippo" is worth 0x5 ; I reset to "0" the third bit of pippo pippo.2 = 0 ; now "pippo" is worth 0x1 ; access the bit of pippo indicated by pluto (fifth bit) pippo = 4 pippo.(pluto) = r(100) ; From RC3E v. 33-01-021: ; access to the bit of pippo indicated by the contents of r(1) pippo.(r(1)) ; access to the bit of pippo indicated by the result of the exp pippo.(r(1)+ pluto*2)
|