Appendix A. CRBasic Programming Instructions
CRBasic Example 70.
Using Bit-Shift Operators
'This program example demonstrates the unpacking of a packed integer. The binary value in
'variable input_val is unpacked resulting in three integers individually stored in variables
'value(1), value(2), and value(3). The information that is unpacked into value(1) is stored
'in 'bits 7 to 6 of input_val, value(2) is unpacked from bits 5 to 4, and value(3) from bits
'3 to 0, zero being the LSB or least-significant bit.
Public
input_val
As Long =
&B01100011
Public
value(3)
As Long
BeginProg
'Unpack the input_val variable by masking all but the bit group of interest by using the
'AND function then shift the bit group to the right until the right-most bit is in the
'LSB position. The result is the unpacked value in decimal.
value(1) = (input_val AND &B11000000)
>>
6
value(2) = (input_val AND &B00110000)
>>
4
value(3) = (input_val AND &B00001111)
'Shifting not needed since right-most bit is already
'in the LSB position.
EndProg
A.7.4 Compound-Assignment Operators
Table 137.
Compound-Assignment Operators
Symbol
Name
Function
^=
Exponent
assignment
Raises the value of a variable to the power of an
expression and assigns the result back to the variable.
*=
Multiplication
assignment
Multiplies the value of a variable by the value of an
expression and assigns the result to the variable.
+=
Addition
assignment
Adds the value of an expression to the value of a
variable and assigns the result to the variable. Also
concatenates a string expression to a variable
declared as STRING data type. Assigns the result to
the variable. See CRBasic example
Concatenation
of Numbers and Strings
(p. 284).
-=
Subtraction
assignment
Subtracts the value of an expression from the value
of a variable and assigns the result to the variable.
/=
Division
assignment
Divides the value of a variable by the value of an
expression and assigns the result to the variable.
\=
Division integer
assignment
Divides the value of a variable by the value of an
expression and assigns the integer result to the
variable.
A.7.5 Logical Operators
AND
Performs a logical conjunction on two expressions.
Syntax
result = expr1 AND expr2
565
Summary of Contents for CR1000
Page 2: ......
Page 4: ......
Page 6: ......
Page 32: ......
Page 36: ......
Page 38: ......
Page 40: ......
Page 60: ...Section 4 System Quickstart Figure 16 PC200W View Line Graph 60 ...
Page 96: ......
Page 98: ...98 ...
Page 302: ......
Page 453: ...Section 8 Operation Figure 115 Using the Keyboard Display 453 ...
Page 456: ...Section 8 Operation Figure 118 Real Time Custom 456 ...
Page 457: ...Section 8 Operation 8 8 1 3 Final Memory Tables Figure 119 Final Memory Tables 457 ...
Page 458: ...Section 8 Operation 8 8 2 Run Stop Program Figure 120 Run Stop Program 458 ...
Page 460: ...Section 8 Operation Figure 122 File Edit 460 ...
Page 461: ...Section 8 Operation 8 8 4 PCCard Memory Card Display Figure 123 PCCard CF Card Display 461 ...
Page 478: ......
Page 506: ......
Page 536: ......
Page 636: ......
Page 642: ......
Page 644: ......
Page 676: ......
Page 677: ......