9.4 Logic object
Description
With the Logic object you can apply logical operations with switches and comparisons with numbers. Additionally you can return different values conditioned by a switch via the
If method.
List of methods/properties
Name | Type | Short description |
Not | Method | Reverses the value of a switch |
And | Method | Applys a logical AND operation with two switches |
Or | Method | Applys a logical OR operations with two switches |
Xor | Method | Applys a logical XOR operation with two switches |
Xnor | Method | Applys a logical XNOR operation with two switches |
Nand | Method | Applys a logical NAND operation with two switches |
Nor | Method | Applys a logical NOR operation with two switches |
Imp | Method | Applys a logical implication operation with two switches |
Inh | Method | Applys a logical inhibit operation with two switches |
And3 | Method | Applys a logical AND operation with three switches |
Or3 | Method | Applys a logical OR operation with three switches |
Xor3 | Method | Applys a logical XOR operation with three switches |
Xnor3 | Method | Applys a logical XNOR operation with three switches |
Nand3 | Method | Applys a logical NAND operation with three switches |
Nor3 | Method | Applys a logical NOR operation with three switches |
Above | Method | Checks whether a value is greater than an other value |
AboveEqual | Method | Checks whether a value is greater/equal than an other value |
Below | Method | Checks whether a value is smaller than an other value |
BelowEqual | Method | Checks whether a value is smaller/equal than an other value |
Equal | Method | Checks whether a value is equals to an other value |
Unequal | Method | Checks whether a value isn't equal to an other value |
If | Method | Returns one of two values conditioned by a switch |
Description
Returns the reversed value of a switch.
Syntax
Truth table
Switch1 | Return value |
0 | 1 |
1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The switch which shall be reversed.
Data type
Switch
Example
1
2
$
s[1] = Logic.Not(True)
s[1] whould be at end: 0 (= False)
Description
Applys a logical AND operation with two switches.
Syntax
1
Logic.And(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.And(True, False)
s[1] whould be at end: 0 (= False)
Description
Applys a logical OR operation with two switches.
Syntax
1
Logic.Or(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Or(False, True)
s[1] whould be at end: 1 (= True)
Description
Applys a logical XOR operation with two switches.
Syntax
1
Logic.Xor(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Xor(True, True)
s[1] whould be at end: 0 (= False)
Description
Applys a logical XNOR operation (equivalence) with two switches.
Syntax
1
Logic.Xnor(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Xnor(False, False)
s[1] whould be at end: 1 (= True)
Description
Applys a logical NAND operation with two switches.
Syntax
1
Logic.Nand(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Nand(True, True)
s[1] whould be at end: 0 (= False)
Description
Applys a logical NOR operation with two switches.
Syntax
1
Logic.Nor(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 1 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Nor(True, False)
s[1] whould be at end: 0 (= False)
Description
Applys a logical implication operation with two switches.
Syntax
1
Logic.Imp(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 1 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Imp(False, True)
s[1] whould be at end: 1 (= True)
Description
Applys a logical inhibit operation with two switches.
Syntax
1
Logic.Inh(Switch1, Switch2)
Truth table
Switch1 | Switch2 | Return value |
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 0 |
1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Inh(False, False)
s[1] whould be at end: 0 (= False)
Description
Applys a logical AND operation with three switches.
Syntax
1
Logic.And3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 0 |
0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.And3(True, True, True)
s[1] whould be at end: 1 (= True)
Description
Applys a logical OR operation with three switches.
Syntax
1
Logic.Or3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Or3(False, False, True)
s[1] whould be at end: 0 (= True)
Description
Applys a logical XOR operation with three switches.
Syntax
1
Logic.Xor3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Xor3(True, True, True)
s[1] whould be at end: 0 (= False)
Description
Applys a logical XNOR operation (equivalence) with three switches.
Syntax
1
Logic.Xnor3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 1 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Xnor3(False, False, False)
s[1] whould be at end: 1 (= True)
Description
Applys a logical NAND operation with three switches.
Syntax
1
Logic.Nand3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 |
0 | 1 | 1 | 1 |
1 | 0 | 0 | 1 |
1 | 0 | 1 | 1 |
1 | 1 | 0 | 1 |
1 | 1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Nand3(True, True, False)
s[1] whould be at end: 1 (= True)
Description
Applys a logical NOR operation with three switches.
Syntax
1
Logic.Nor3(Switch1, Switch2, Switch3)
Truth table
Switch1 | Switch2 | Switch3 | Return value |
0 | 0 | 0 | 1 |
0 | 0 | 1 | 0 |
0 | 1 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 0 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
Return value
Switch
Type
Method
Parameter: Switch1
Description
The first switch which shall be operated.
Data type
Switch
Parameter: Switch2
Description
The second switch which shall be operated.
Data type
Switch
Parameter: Switch3
Description
The third switch which shall be operated.
Data type
Switch
Example
1
2
$
s[1] = Logic.Nor3(False, True, False)
s[1] whould be at end: 0 (= False)
Description
Compares two numeric values an returns true if the first value is greater than the second value.
Syntax
1
Logic.Above(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.Above(1, 7)
s[1] whould be at end: 0 (= False)
Description
Compares two numeric values an returns true if the first value is greater/equal than the second value.
Syntax
1
Logic.AboveEqual(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.AboveEqual(6, 6)
s[1] whould be at end: 1 (= True)
Description
Compares two numeric values an returns true if the first value is smaller than the second value.
Syntax
1
Logic.Below(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.Below(1, 20)
s[1] whould be at end: 1 (= True)
Description
Compares two numeric values an returns true if the first value is smaller/equal than the second value.
Syntax
1
Logic.BelowEqual(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.BelowEqual(71, 2)
s[1] whould be at end: 0 (= False)
Description
Compares two numeric values an returns true if the first value equals to the second value.
InformationThis method compares only numbers. If you want to compare string then you must use the
Compare method of the
String object. If you want to compare switches then you must use the
Xnor method of this object.
Syntax
1
Logic.Equal(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.Equal(7, 6)
s[1] whould be at end: 0 (= False)
Description
Compares two numeric values an returns true if the first value doesn't equal to the second value.
InformationThis method compare only numbers. If you want to compare strings for inequality then you must use the
Compare method of the
String object and reverse the result with the
Not method of this object. If you want to compare switches for inequality then you must use the
Xor method of this object.
Syntax
1
Logic.Unequal(Number1, Number2)
Return value
Switch
Type
Method
Parameter: Number1
Description
The first number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Parameter: Number2
Description
The second number which shall be compared.
Data type
All numbers
Range
Depends on the data type
Example
1
2
$
s[1] = Logic.Unequal(12, 8)
s[1] whould be at end: 1 (= True)
Description
Returns a value conditioned by the value of a switch. If the switch is True then TrueValue will be returned, otherwise FalseValue will be returned.
Information
The values including the data types of the parameters will be returned. However you can't use this method for a writing operation.
Syntax
1
Logic.If(Expression, TrueValue, FalseValue)
Return value
Either TrueValue or FalseValue (depends on the value of Expression).
Type
Method
Parameter: Expression
Description
Decides whether TrueValue or FalseValue returns.
Data type
Switch
Parameter: TrueValue
Description
Will be returned only if Expression is true.
Data type
All
Parameter: FalseValue
Description
Will be returned only if Expression is false.
Data type
All
Example
1
2
$
a[1] = Logic.If(True, "marmalade", "cake")
a[1] whould be at end: "marmalade"