PDA

View Full Version : Why does |= not work?



ReneMiner
26-02-2015, 12:44
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

Michael Clease
27-02-2015, 13:17
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.

ReneMiner
27-02-2015, 14:38
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.

John Spikowski
28-02-2015, 11:08
In traditional BASIC. <> is not equal.

ReneMiner
01-03-2015, 08:19
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

Petr Schreiber
01-03-2015, 09:32
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

ReneMiner
02-03-2015, 09:30
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)