View Full Version : newbe: IF..THEN statement
ShawnB
- 10th November 2009, 23:45
When using the IF..Then statement how many comparison terms can you have? Is the following a legal instruction:
IF (PORTA.0 = 1 AND PORTA.1 = 1) OR (PORTA.2 = 1) THEN PORTB.0 = 1
Any help would be appreciated
thank you,
Shawn
rsocor01
- 11th November 2009, 00:32
No, your line is not legal. Replace it by
IF (PORTA.0=1) AND (PORTA.1=1) THEN PORTB.0=1
IF PORTA.2=1 THEN PORTB.0=1
Robert
financecatalyst
- 11th November 2009, 00:35
Or...
If ((porta.0 = 1) and (porta.1 = 1)) or (porta.2 = 1) then portb.0 = 1
aratti
- 11th November 2009, 01:03
Since the three inputs are all on the same port, then you can tray:
A0 var BYTE
A0 = PortA.0 + PortA.1 + PortA.2
If A0 > 2 then PortB.0 = 1
or.....
IF PortA & %00000111 > 2 then portB.0 = 1
Al.
ShawnB
- 11th November 2009, 14:07
Thank you very much, this is very helpful.
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.