# Thread: Why does |= not work?

1. ## Why does |= not work?

i thought it were logical to assign something additional using OR as simple as this - but it does not work

```Uses "console"

Long lTest

lTest |= 1                     ' should equal  lTest = lTest | 1
PrintL lTest

WaitKey
```  Reply With Quote

2. because this isn't C its ThinBasic!

```result = ANDb (Num1, Num2) ' Used to perform AND bitwise operations.
result = ORb (Num1, Num2) 'Used to perform OR bitwise operations.
result = expression1 OR expression2  ' Used to perform a logical disjunction on two expressions.
| ' Alias of Or opertaor.
```  Reply With Quote

3. Yes correct.

We have
```a += b
```
which is just shorter and means the same as
```a = a + b
```
also there are similar operations as -=, *= etc.

but no
```a |= b
' that means
a = a | b
```
i was wondering because i typed it in that way, no doubt that it would work - but it does not.  Reply With Quote

4. In traditional BASIC. <> is not equal.  Reply With Quote

5. no, maybe it was a little vague, i did not write

!=
c-like "NOT equal"

but

|=
basic-like "equals Itself OR Parameter"

logic numeric operator that will prove "3 = 2 OR 1"

A = A OR B

A |= B  Reply With Quote

6. The note by Michael is good one,

maybe if AND() and OR() could be used for logical, not bitwise operations, it would be nice.

Petr  Reply With Quote

7. For implicit assignement there are already available:

+=, -=, *=, /=, \=

We also have &= and += that are doing the same when it comes to stringExpressions, used to concatenate such.

and these were reasoned to have:

implicit AND
&=

numericVar &= numericExpression

would equal
numericVar = (numericVar AND numericExpression)

implicit OR
|=

numericVar |= numericExpression

equals then
numericVar = (numericVar OR numericExpression)

stringVar |= stringExpression

equals
stringVar = IIF\$(Instr(stringVar, stringExpression), stringVar, stringVar & stringExpression)  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•