![]() |
Forum Index : Microcontroller and PC projects : If Else Execution.
Author | Message | ||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Regarding Executions of IF statements. Am I correct in thinking that once an IF or ELSE IF statement returns TRUE, that the remaining test statements are skipped? IE. Test1=False, Test2=True, Tests 3 & 4 are then ignored? [Code] IF Test1 THEN Instruction1 Else IF Test2 THEN Instruction2 Else IF Test2 THEN Instruction2 Else IF Test3 THEN Instruction3 Else IF Test4 THEN Instruction4 END IF [/code] Thanks Phil |
||||
CircuitGizmos![]() Guru ![]() Joined: 08/09/2011 Location: United StatesPosts: 1421 |
Try it. Micromites and Maximites! - Beginning Maximite |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Not near any of my MM stuff this morning, Hence churning over code in my head re a logic solution. Cheers. Will get to try some test code later.... ![]() |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 5950 |
The answer is "Yes". Careful juggling with the order of the statements can make a big difference to the complexity and performance. You might also want to consider SELECT..CASE as a cleaner option, depending on your conditional statements. Jim VK7JH MMedit MMBasic Help |
||||
![]() |