Help with an if / elseif
17 Apr 2022 06:41 #240442
by Nitram
Help with an if / elseif was created by Nitram
Hello.
Just wondering why my nested "if" sub ( o100 ) is not working. I want to stop a larger subroutine ( o<tool_length_probe> ) if the user has forgotten to put in a variable value i.e. left a zero.
When I test, it doesn't operate, but rather just skips over the sub and continues running on its merry way...
o100 if [#10 EQ 0]
elseif [#11 EQ 0]
elseif [#12 EQ 0]
elseif [#13 EQ 0]
elseif [#14 EQ 0]
elseif [#15 EQ 0]
elseif [#16 EQ 0]
elseif [#17 EQ 0]
elseif [#18 EQ 0]
(MSG, SOME PARAMETERS IN MACRO FILE NOT SET)
o<tool_length_probe> endsub
M2
o100 endif
Many thanks.
Just wondering why my nested "if" sub ( o100 ) is not working. I want to stop a larger subroutine ( o<tool_length_probe> ) if the user has forgotten to put in a variable value i.e. left a zero.
When I test, it doesn't operate, but rather just skips over the sub and continues running on its merry way...
o100 if [#10 EQ 0]
elseif [#11 EQ 0]
elseif [#12 EQ 0]
elseif [#13 EQ 0]
elseif [#14 EQ 0]
elseif [#15 EQ 0]
elseif [#16 EQ 0]
elseif [#17 EQ 0]
elseif [#18 EQ 0]
(MSG, SOME PARAMETERS IN MACRO FILE NOT SET)
o<tool_length_probe> endsub
M2
o100 endif
Many thanks.
Please Log in or Create an account to join the conversation.
17 Apr 2022 09:17 #240448
by MaHa
Replied by MaHa on topic Help with an if / elseif
This untested idea with many 'OR' in one line and 'abort'
o<tool_length_probe> sub
o100 IF [[#1 EQ 0] OR [#2 EQ 1] OR [#3 EQ 0] OR [#4 EQ 2] OR [#5 EQ 0]]
(abort, SOME PARAMETERS IN MACRO FILE NOT SET)
o<tool_length_probe> RETURN
o100 endif
o<tool_length_probe> endsub
M2
Please Log in or Create an account to join the conversation.
17 Apr 2022 09:32 - 17 Apr 2022 15:20 #240449
by Nitram
Replied by Nitram on topic Help with an if / elseif
After some more reading I think it might need:
1. The sub number with each elseif and
2. The action to be taken with each elseif I.e. repeat
(MSG, SOME PARAMETERS IN MACRO FILE NOT SET)
o<tool_length_probe> endsub
M2
after each elseif so the interpreter knows what to do if any single elseif tests true...
Regarding the above, I'm interested to see whether an or statement works
1. The sub number with each elseif and
2. The action to be taken with each elseif I.e. repeat
(MSG, SOME PARAMETERS IN MACRO FILE NOT SET)
o<tool_length_probe> endsub
M2
after each elseif so the interpreter knows what to do if any single elseif tests true...
Regarding the above, I'm interested to see whether an or statement works
Last edit: 17 Apr 2022 15:20 by Nitram.
Please Log in or Create an account to join the conversation.
17 Apr 2022 21:37 #240495
by Nitram
Replied by Nitram on topic Help with an if / elseif
The OR statement did work in this context.
Thanks!
Thanks!
Please Log in or Create an account to join the conversation.
19 Apr 2022 23:52 #240707
by andypugh
Replied by andypugh on topic Help with an if / elseif
You could also use [[#1 AND #2 AND #3] EQ 0] as zero == false.
The following user(s) said Thank You: Nitram
Please Log in or Create an account to join the conversation.
Time to create page: 0.140 seconds