# Scheduling lights with more randomness

The last end if can be omitted if there is not following action. RM is forgiving when it comes to that

That is what is baffling about this. It is hard to tell if they are needed because like you said it runs OK. I dunno! The reason I asked about it being 2 endif's missing was the fact you have 2 IF's and a endif but only 1 endif at the end. Go figure!

So you are saying the only endif can be eliminated? That makes it even more confusing!

Technically, you can also forget the END REP if it is the last entry for the rule. I for one, would recommend to always add them, no matter what. That takes all the confusion out.

Wow, another question would be that if you do add the proper number and placement of endif's could that cause the rule not to run correctly?

What exactly is the rule of thumb on this?

If you do NOT add the proper once, yes it can.

Here are some examples:

``````----START OF RULE
START REP
DO REPEATED ACTION 1
DO REPEATED ACTION 2
END-REP
----END OF RULE
``````

Is the same as:

``````----START OF RULE
START REPEAT
DO REPEATED ACTION 1
DO REPEATED ACTION 2
----END OF RULE
``````

However, let's say you want to execute one more thing AFTER the repeat finished, that would correctly look like this:

``````----START OF RULE
START REP
DO REPEATED ACTION 1
DO REPEATED ACTION 2
END-REP
DO ACTION THAT IS NOT REPEATED
----END OF RULE
``````

Here, the END-REP is very important. If the END-REP wouldn't be there that last entry would become part of the repeat and would be executed with the repeat over and over again.

It would be executed as this:

``````----START OF RULE
START REPEAT
DO REPEATED ACTION 1
DO REPEATED ACTION 2
DO ACTION THAT IS NOT REPEATED BUT I AM DOING IT REPEATED SINCE I FORGOT THE END REP
----END OF RULE
``````

Which is not what you wanted. It is literally limited to what is the last entry of the rule, not just of the repeat or the if. Bottom line, get into the habit of adding the END-IF and END-REP and you will protect yourself of the rule doing something that you didn't want it to do

Add the proper END-... and your thumbs stay intact

Nice. Thanks. I will continue to add them just in case. So far I have all working correctly. I do see the differences in what you are saying. Knowing about the last entry helps.