Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:27 17 Jun 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : If Else Execution.

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 11:49am 14 Jun 2016
Copy link to clipboard 
Print this post

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 States
Posts: 1421
Posted: 01:04pm 14 Jun 2016
Copy link to clipboard 
Print this post

Try it.


Micromites and Maximites! - Beginning Maximite
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 04:02pm 14 Jun 2016
Copy link to clipboard 
Print this post

  CircuitGizmos said   Try it.



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: Australia
Posts: 5950
Posted: 09:32pm 14 Jun 2016
Copy link to clipboard 
Print this post

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
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024