View Full Version : Multiple ORs in an IF statement
Demon
- 25th August 2024, 03:59
if COM_KHz_Remainder = 995 then
COM_KHz_Counter = 000
else
COM_KHz_Remainder = COM_KHz_Counter // 100
if (COM_KHz_Remainder = 20) or
(COM_KHz_Remainder = 45) or
(COM_KHz_Remainder = 70) or
(COM_KHz_Remainder = 95) then
COM_KHz_Counter = COM_KHz_Counter + 5
endif
endif
I can't seem to find a proper syntax for those quadruple ORs...?
Demon
- 25th August 2024, 04:03
The only way I could get it to compile:
if COM_KHz_Remainder = 995 then
COM_KHz_Counter = 000
else
COM_KHz_Remainder = COM_KHz_Counter // 100
if COM_KHz_Remainder = 20 then COM_KHz_Counter = COM_KHz_Counter + 5
if COM_KHz_Remainder = 45 then COM_KHz_Counter = COM_KHz_Counter + 5
if COM_KHz_Remainder = 70 then COM_KHz_Counter = COM_KHz_Counter + 5
if COM_KHz_Remainder = 95 then COM_KHz_Counter = COM_KHz_Counter + 5
endif
HenrikOlsson
- 25th August 2024, 10:00
When splitting a statement across multiple lines like that you need to use line extension charachter ( _ ).
Section 2.17 in the manual.
Demon
- 26th August 2024, 18:23
if (COM_KHz_Remainder = 20) or _
(COM_KHz_Remainder = 45) or _
(COM_KHz_Remainder = 70) or _
(COM_KHz_Remainder = 95) then
COM_KHz_Counter = COM_KHz_Counter + 5
endif
That feeling when you missed something totally obvious; well that's what I'm feeling right now.
:D
And then the REALLY dumb feeling is when you notice you were doing it properly on LCDOUT command all that time...
:p
Ioannis
- 27th August 2024, 09:42
Don't worry. It happens to all...!
Ioannis
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.