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

NameTypeShort description
NotMethodReverses the value of a switch
AndMethodApplys a logical AND operation with two switches
OrMethodApplys a logical OR operations with two switches
XorMethodApplys a logical XOR operation with two switches
XnorMethodApplys a logical XNOR operation with two switches
NandMethodApplys a logical NAND operation with two switches
NorMethodApplys a logical NOR operation with two switches
ImpMethodApplys a logical implication operation with two switches
InhMethodApplys a logical inhibit operation with two switches
And3MethodApplys a logical AND operation with three switches
Or3MethodApplys a logical OR operation with three switches
Xor3MethodApplys a logical XOR operation with three switches
Xnor3MethodApplys a logical XNOR operation with three switches
Nand3MethodApplys a logical NAND operation with three switches
Nor3MethodApplys a logical NOR operation with three switches
AboveMethodChecks whether a value is greater than an other value
AboveEqualMethodChecks whether a value is greater/equal than an other value
BelowMethodChecks whether a value is smaller than an other value
BelowEqualMethodChecks whether a value is smaller/equal than an other value
EqualMethodChecks whether a value is equals to an other value
UnequalMethodChecks whether a value isn't equal to an other value
IfMethodReturns one of two values conditioned by a switch

Not

Description

Returns the reversed value of a switch.

Syntax

1
Logic.Not(Switch1)

Truth table

Switch1Return value
01
10

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)

And

Description

Applys a logical AND operation with two switches.

Syntax

1
Logic.And(Switch1, Switch2)

Truth table

Switch1Switch2Return value
000
010
100
111

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)

Or

Description

Applys a logical OR operation with two switches.

Syntax

1
Logic.Or(Switch1, Switch2)

Truth table

Switch1Switch2Return value
000
011
101
111

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)

Xor

Description

Applys a logical XOR operation with two switches.

Syntax

1
Logic.Xor(Switch1, Switch2)

Truth table

Switch1Switch2Return value
000
011
101
110

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)

Xnor

Description

Applys a logical XNOR operation (equivalence) with two switches.

Syntax

1
Logic.Xnor(Switch1, Switch2)

Truth table

Switch1Switch2Return value
001
010
100
111

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)

Nand

Description

Applys a logical NAND operation with two switches.

Syntax

1
Logic.Nand(Switch1, Switch2)

Truth table

Switch1Switch2Return value
001
011
101
110

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)

Nor

Description

Applys a logical NOR operation with two switches.

Syntax

1
Logic.Nor(Switch1, Switch2)

Truth table

Switch1Switch2Return value
001
010
100
110

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)

Imp

Description

Applys a logical implication operation with two switches.

Syntax

1
Logic.Imp(Switch1, Switch2)

Truth table

Switch1Switch2Return value
001
011
100
111

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)

Inh

Description

Applys a logical inhibit operation with two switches.

Syntax

1
Logic.Inh(Switch1, Switch2)

Truth table

Switch1Switch2Return value
000
011
100
110

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)

And3

Description

Applys a logical AND operation with three switches.

Syntax

1
Logic.And3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0000
0010
0100
0110
1000
1010
1100
1111

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)

Or3

Description

Applys a logical OR operation with three switches.

Syntax

1
Logic.Or3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0000
0011
0101
0111
1001
1011
1101
1111

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)

Xor3

Description

Applys a logical XOR operation with three switches.

Syntax

1
Logic.Xor3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0000
0011
0101
0110
1001
1010
1100
1110

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)

Xnor3

Description

Applys a logical XNOR operation (equivalence) with three switches.

Syntax

1
Logic.Xnor3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0001
0010
0100
0110
1000
1010
1100
1111

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)

Nand3

Description

Applys a logical NAND operation with three switches.

Syntax

1
Logic.Nand3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0001
0011
0101
0111
1001
1011
1101
1110

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)

Nor3

Description

Applys a logical NOR operation with three switches.

Syntax

1
Logic.Nor3(Switch1, Switch2, Switch3)

Truth table

Switch1Switch2Switch3Return value
0001
0010
0100
0110
1000
1010
1100
1110

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)

Above

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)

AboveEqual

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)

Below

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)

BelowEqual

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)

Equal

Description

Compares two numeric values an returns true if the first value equals to the second value.
Information
This 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)

Unequal

Description

Compares two numeric values an returns true if the first value doesn't equal to the second value.
Information
This 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)

If

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"