IF Alternative?

Just checking…(I dont have hardware to test this on right now)
A typical simple IF statement is:

10 IF VAR1 AND VAR2 THEN VAR3 (all VARs are Boolean)

Can this also be written…?

20 VAR3 = VAR1 AND VAR2

10 IF VAR1 AND VAR2 AND VAR3 THEN do something here.

20 VAR3 = VAR1 AND VAR2

This might work but I’d rework it something clearer and easier for the next guy to maintain:

30 IF VAR1 AND VAR2 THEN START VAR3 ELSE STOP VAR3

I cannot have explained myself well enough…

I am wondering if it is possible to do simple logic-operations INSTEAD OF using an IF statement. I realise this is not suitable to achieve a complex result, but if the only reason for an IF-statement is to combine two variables into a third, I wonder if this is possible.

So my question is, can the statement:
10 IF VAR1 AND VAR2 THEN VAR3 = 1 ELSE VAR3 = 0
be replaced by the statement
10 VAR3 = VAR1 AND VAR2

This could be useful as a compact precursor to an IF statement with a large number of input conditions, eg

10 VAR6 = VAR1 AND VAR2 AND VAR3 AND VAR4 AND VAR5
20 IF VAR6 THEN [required outcome] ELSE [something else]

I am just not sure of the kind of logical operation described above is “allowed”.

I havent tried i before, why dont you give it a try and report back here.

I tried with three simple expressions
10 VAR1 = VAR2 AND VAR3
and
10 VAR1 = VAR2 OR VAR3
and
10 VAR1 = VAR2 AND NOT VAR3

VAR1,2,3 with Units 1 (Off/On)
VAR2 and VAR3 in Manual.

all expressions evaluated correctly.

These are equivalent to:
10 IF VAR2 AND VAR3 THEN VAR1 = 1 ELSE VAR1 = 0
10 IF VAR2 OR VAR3 THEN VAR1 = 1 ELSE VAR1 = 0
10 IF VAR2 AND NOT VAR3 THEN VAR1 = 1 ELSE VAR1 = 0
but much more compact in the program listing - although there is very little difference in memory used.

Of course this does not replace IF statement in all cases, but useful nevertheless. I see an important use in combining many inputs where a regular IF statement would overflow onto 2 lines.

I was a bit lazy with my reply, I admit. Thanks very much for confirming.

Just checking as the documentation is not perfectly clear…

Am I correct that in Boolean expressions the default order of execution within a single statement is NOT then OR then AND ??

I notice that T3000 usually removes parentheses but this seems to change the intention, eg in the part-statement
… ( VAR1 AND VAR2 ) OR VAR3…
I want to perform the (VAR1 AND VAR2) first and then OR that result with VAR3.

When I F2 ‘Send’ this, the parentheses are removed, but wont this result in
… VAR AND ( VAR2 OR VAR3 ) which is not what I intend ??

The order from top to bottom is:
NOT
AND
OR

My suggestion is keep it simple, make it easy for the next guy to maintain this 5-10 years down the road:
-One concept or function per line.
-Lines at the bottom will override lines further up in the program.

Thanks - I’m glad I checked - I had the order wrong

Still should confirm first, and my recommendation again is to steer away from such complex statements. Simpler programs will be easier to maintain later on.