Intermec IV7 Basic Reader Interface Programmer's Reference Manual (BRI version - Page 44

Grouping Expressions Without Using Parentheses

Page 44 highlights

Chapter 3 - Understanding BRI Programming Elements Therefore, tags are selected only if there is a 3 at location 21 and either a 1 or a 2 at locations 19 and 20 respectively. It is important to note that the AND/OR keywords apply to the condition that follows. The first term in a WHERE expression always has an implied OR and includes tags that contain the specified data. You can write the previous example differently and still achieve the same result, as shown in the following example. READ INT(18) WHERE INT(20)=2 AND INT(21)=3 OR INT(19)=1 The WHERE expression is evaluated from left to right as follows: • Include all tags if the data at address 20 equals 2. • Exclude all tags if the data at address 21 does not equal 3. • Include all tags if the data at address 19 equals 1. Therefore, tags are selected only if there is a 3 at location 21 and either a 1 or a 2 at locations 19 and 20 respectively. Grouping Expressions Without Using Parentheses You cannot use parentheses to group expressions using AND/OR logic. Therefore, it may be difficult to implement an expression using the AND/OR logic without a great deal of planning. To allow some primitive grouping in defining WHERE expressions, the AND/OR expression logic has been modified. Every time an AND expression is followed by an OR, the expression following the OR starts a new tag selection criteria. The following example illustrates this concept, but also adds a variation in expression evaluation. Using the previous example, the next two examples evaluate differently, strictly due to the order of the data in the expression. In the following example, the WHERE expression evaluates exactly as described above. READ INT(18) WHERE INT(19)=1 OR INT(20)=1 AND INT(21)=3 However, the following example changes the order of the expression, so the resulting tags selected are evaluated as if parentheses were being used: READ INT(18) WHERE INT(20)=1 AND INT(21)=3 OR INT(19)=1 Because an OR follows an AND, the expression is evaluated as follows using parentheses: READ INT(18) WHERE ( INT(20)=1 AND INT(21) ) OR INT(19)=1 Implied parentheses are applied any time an OR keyword follows an AND keyword. Suppose you must find a tag that contains the following information: four-byte STRING data at location 18 with data NAME, two-byte INT data at location 22 with data 17, and one-byte INT data at location 24 with data E. The expression that describes this tag is shown below: STRING(18,4)="NAME" AND INT(22,1)=17 AND INT(24,1)='E' 32 Basic Reader Interface Programmer Reference Manual

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146

Chapter 3 — Understanding BRI Programming Elements
32
Basic Reader Interface Programmer Reference Manual
Therefore, tags are selected only if there is a 3 at location 21 and either a 1 or a 2 at
locations 19 and 20 respectively.
It is important to note that the AND/OR keywords apply to the condition that
follows. The first term in a WHERE expression always has an implied OR and
includes tags that contain the specified data.
You can write the previous example differently and still achieve the same result, as
shown in the following example.
READ INT(18) WHERE INT(20)=2 AND INT(21)=3 OR INT(19)=1
The WHERE expression is evaluated from left to right as follows:
Include all tags if the data at address 20 equals 2.
Exclude all tags if the data at address 21 does not equal 3.
Include all tags if the data at address 19 equals 1.
Therefore, tags are selected only if there is a 3 at location 21 and either a 1 or a 2 at
locations 19 and 20 respectively.
Grouping Expressions Without Using Parentheses
You cannot use parentheses to group expressions using AND/OR logic. Therefore, it
may be difficult to implement an expression using the AND/OR logic without a
great deal of planning. To allow some primitive grouping in defining WHERE
expressions, the AND/OR expression logic has been modified. Every time an AND
expression is followed by an OR, the expression following the
OR
starts a new tag
selection criteria. The following example illustrates this concept, but also adds a
variation in expression evaluation. Using the previous example, the next two
examples evaluate differently, strictly due to the order of the data in the expression.
In the following example, the WHERE expression evaluates exactly as described
above.
READ INT(18) WHERE INT(19)=1 OR INT(20)=1 AND INT(21)=3
However, the following example changes the order of the expression, so the resulting
tags selected are evaluated as if parentheses were being used:
READ INT(18) WHERE INT(20)=1 AND INT(21)=3 OR INT(19)=1
Because an OR follows an AND, the expression is evaluated as follows using
parentheses:
READ INT(18) WHERE ( INT(20)=1 AND INT(21) ) OR INT(19)=1
Implied parentheses are applied any time an OR keyword follows an AND keyword.
Suppose you must find a tag that contains the following information: four-byte
STRING data at location 18 with data
NAME
, two-byte INT data at location 22 with
data
17
, and one-byte INT data at location 24 with data
E
. The expression that
describes this tag is shown below:
STRING(18,4)=”NAME” AND INT(22,1)=17 AND INT(24,1)=’E’