Jump to content

Nested "Repeat"


yardman 49

Recommended Posts

Posted

Hello all:

 

I want to use "Repeat" in some of my programs where I currently use repeating manual entries. For instance, I will often issue X10 commands two or three times in a row, with 2 second waits in between.

 

I know that I can use "Repeat" for this. But I'm confused as to what gets repeated, and how to continue on with the "Then" statement without continuing to repeat the remainder of the actions. It seems from what I can tell that once you insert "Repeat" into a "Then" statement, the remainder of the commands would be automatically "nested" under that Repeat. It appears there then is no way to end the Repeat argument without issuing another "Repeat", even if that is a "Repeat 1 times".

 

So for example, here is my "Outside Lights On" program:

 

 

If

From Sunset - 10 minutes

For 1 hour

 

Then

Set 'Hall KPL A - Porch Light' 50%

Wait 3 seconds

 

Send X10 'E1/On (3)'

Wait 2 seconds

Send X10 'E1/On (3)'

Wait 2 seconds

Send X10 'E1/On (3)'

 

Wait 10 seconds

 

Send X10 'E2/On (3)'

Wait 2 seconds

Send X10 'E2/On (3)'

Wait 2 seconds

Send X10 'E2/On (3)'

 

Else

- No Actions - (To add one, press 'Action')

 

 

Would I use the following to rewrite this using "Repeat"?:

 

If

From Sunset - 10 minutes

For 1 hour

 

Then

Set 'Hall KPL A - Porch Light' 50%

Wait 3 seconds

 

Repeat 3 times

Send X10 'E1/On (3)'

Wait 2 seconds

 

Repeat 1 times

Wait 10 seconds

 

Repeat 3 times

Send X10 'E2/On (3)'

Wait 2 seconds

 

Else

- No Actions - (To add one, press 'Action')

 

But this seems rather weird. Shoudn't there be a way to add more commands without having to put all the non-repeating ones into a "Repeat 1 times" argument? It would seem better to have allowed the use of parenthetical nesting arguments, such that everything to be repeated has to be contained in a parenthesis directly following the "Repeat" command.

 

 

 

Thanks!

Posted

Your usage of Repeat and Repeat 1 times is correct; repeats are processed sequentially and are not nested.

 

But this seems rather weird. Shoudn't there be a way to add more commands without having to put all the non-repeating ones into a "Repeat 1 times" argument? It would seem better to have allowed the use of parenthetical nesting arguments, such that everything to be repeated has to be contained in a parenthesis directly following the "Repeat" command.

 

If we support nested Repeat in the future, we will more than likely use parentheses, much like the way the Add And (...) and Add Or (...) buttons work.

Posted
Your usage of Repeat and Repeat 1 times is correct; repeats are processed sequentially and are not nested.

 

But this seems rather weird. Shoudn't there be a way to add more commands without having to put all the non-repeating ones into a "Repeat 1 times" argument? It would seem better to have allowed the use of parenthetical nesting arguments, such that everything to be repeated has to be contained in a parenthesis directly following the "Repeat" command.

 

If we support nested Repeat in the future, we will more than likely use parentheses, much like the way the Add And (...) and Add Or (...) buttons work.

 

Hello Chris:

 

Thanks for the reply. So am I correct in assuming that the only way to break the repeat sequence for any subsequent commands is to use "Repeat 1 Times" ?

 

So lets say that in my previous example, after I have issued all of my X10 "repeats", I then want to add a 30 minute wait, followed by more Insteon commands and waits. Would the 30 minute wait and successive Insteon commands have to be preceeded by a "Repeat 1 Times" as follows:

 

If

From Sunset - 10 minutes

For 1 hour

 

Then

Set 'Hall KPL A - Porch Light' 50%

Wait 3 seconds

 

Repeat 3 times

Send X10 'E1/On (3)'

Wait 2 seconds

 

Repeat 1 times

Wait 10 seconds

 

Repeat 3 times

Send X10 'E2/On (3)'

Wait 2 seconds

 

Repeat 1 times

Wait 30 minutes

Set Scene 'Kitchen Sink Group' On

Wait 3 seconds

Set Scene 'Kitchen Island Group' On

Wait 3 seconds

Set Scene 'Living Room Group' On

Wait 10 minutes

Set Scene 'Basement Stairway Group' On

Wait 3 seconds

Set Scene 'Basement Sconce Group' On

 

 

Else

- No Actions - (To add one, press 'Action')

 

 

If this is the correct way to write such a program, I will update the Wiki with this information.

 

Thank you.

Posted

Thanks for the reply. So am I correct in assuming that the only way to break the repeat sequence for any subsequent commands is to use "Repeat 1 Times" ?

 

Hi Frank,

 

Yes, this is the correct and only way to break the repeat sequence.

Posted
Your usage of Repeat and Repeat 1 times is correct; repeats are processed sequentially and are not nested.

 

But this seems rather weird. Shoudn't there be a way to add more commands without having to put all the non-repeating ones into a "Repeat 1 times" argument? It would seem better to have allowed the use of parenthetical nesting arguments, such that everything to be repeated has to be contained in a parenthesis directly following the "Repeat" command.

 

If we support nested Repeat in the future, we will more than likely use parentheses, much like the way the Add And (...) and Add Or (...) buttons work.

 

Hello Chris & Michel:

 

Until nested Repeats are implimented, could you consider these alternatives?:

 

1) When a "Repeat 1 times" is used to "break" a repeat sequence, could you please have the GUI "remove the indent" on successive actions? Currently, using this approach to break the repeat sequence still leaves all the following lines indented (although this is not visible when pasting here to the forum). Having them indented is confusing.

 

2) Allow a "Repeat End" to be selected from the drop down for "Repeat For X". This basically should only require the change of the Repeat "1" selection, so that the 1 gets substituted with "End". Unless I'm missing something, since Repeat "1" times really doesn't "repeat" at all, would this not just be a GUI change? If this is implemented, then point 1) above should also be implimented as part of this.

 

 

Thank you and Best Wishes,

Posted

Frank,

 

I had thought about adding 'Repeat End' as well, but its not as simple as it first sounds ...

 

Basically, to do this right, 'Repeat End' would have to be added at the same time as the 'Repeat X times' entry (like the parens for the [Add And (..)] button). But without nested Repeats, adding 'Repeat End' will only add confusion and frustration as people try to nest Repeats but cannot. If we simple add 'Repeat End' as an option alone, syntactically incorrect programs could be written:

 

i.e. Would need to prevent this scenario

Then
  Repeat End
  Repeat 3 Times
  Repeat 2 Times
  Repeat End
  Repeat End

 

If support for nested Repeats is added in a future release then using 'Repeat End' or parentheses makes a lot of sense, but until then I think it is best to leave it as-is .

Posted
Frank,

 

I had thought about adding 'Repeat End' as well, but its not as simple as it first sounds ...

 

Basically, to do this right, 'Repeat End' would have to be added at the same time as the 'Repeat X times' entry (like the parens for the [Add And (..)] button). But without nested Repeats, adding 'Repeat End' will only add confusion and frustration as people try to nest Repeats but cannot. If we simple add 'Repeat End' as an option alone, syntactically incorrect programs could be written:

 

i.e. Would need to prevent this scenario

Then
  Repeat End
  Repeat 3 Times
  Repeat 2 Times
  Repeat End
  Repeat End

 

If support for nested Repeats is added in a future release then using 'Repeat End' or parentheses makes a lot of sense, but until then I think it is best to leave it as-is .

 

Hello Chris:

 

I guess that my question then is: Is "Repeat 1 times" any less confusing? When would anyone use "Repeat 1" other than to break the sequence?

Posted

I guess that my question then is: Is "Repeat 1 times" any less confusing? When would anyone use "Repeat 1" other than to break the sequence?

 

Frank,

 

People may use 'Repeat 1' (and 'Repeat 0' for that matter) when writing their programs and testing them.

 

The GUI ensures that your program is syntactically correct at all times. The only way to do this with 'Repeat End', is to add it as a 'Repeat X Times/Repeat End' pair, like parentheses. This is what will be added if nested Repeats are supported.

 

Its not just as simple as replacing 'Repeat 1 times' with 'Repeat End', as the following examples show:

 

The point is, there is no trivial change that will fix this, therefore if we make any change it makes sense to just include nested repeats as part of that change.

 

Example #1 : Syntax is correct

Then 
  Repeat 1 Times 
     Set 'Light' Brighten
  Repeat 3 Times 
     Set 'Light' Dim
  Repeat 2 Times 
     Set 'Light' Brighten
  Repeat 1 Times 
     Set 'Light' Dim
  Repeat 1 Times 
     Set 'Light' Brighten

 

Example #2: Replacing 'Repeat 1 Times' with 'Repeat End' 

Syntax is incorrect

Then 
  Repeat End
     Set 'Light' Brighten
  Repeat 3 Times 
     Set 'Light' Dim
  Repeat 2 Times 
     Set 'Light' Brighten
  Repeat End
     Set 'Light' Dim
  Repeat End
     Set 'Light' Brighten

Posted

Hello Chris:

 

Sorry to be a pest on this, but if this is the way that things must be for now, I could use a little more clarification:

 

Repeat 2 times = A) Run the following actions twice? B) Or does this mean "Run the following actions, then run them twice more, for a total of three runs??

 

(Depending on the correct answer to this question, the next questions may become irrelevant.)

 

Repeat 1 times = A) Run the following actions once? So then this is exactly the same as not using any "Repeat", except that it breaks the sequence? B) Unless this really means "Run the following actions once, then run them once more", for a total of two times.

 

In your examples, you have "Set 'Light' Brighten" preceeded by "Repeat 1 Times". But I'm confused as to why this would ever be used in this way, if my first assumption is true; since there's no sequence to break at this point, so why bother?

 

Repeat 0 times = A) Don't run any of the following actions at all?? When would this be used? B) Or does this mean "Run the following actions once, and then don't repeat them", for a total of one time through the actions?

 

Whew! Sorry if I'm a little dense on this. I just want to be certain that I'm perfectly clear in my understanding.

 

And thanks for your patience!

 

 

Best wishes,

Posted

Repeat 2 times = A) Run the following actions twice? B) Or does this mean "Run the following actions, then run them twice more, for a total of three runs??

Yes, this means run the following actions a total of two times.

 

Repeat 1 times = A) Run the following actions once? So then this is exactly the same as not using any "Repeat", except that it breaks the sequence? B) Unless this really means "Run the following actions once, then run them once more", for a total of two times.

Yes, this means run the following actions once.

 

In your examples, you have "Set 'Light' Brighten" preceeded by "Repeat 1 Times". But I'm confused as to why this would ever be used in this way, if my first assumption is true; since there's no sequence to break at this point, so why bother?

You wouldn't bother doing that, it was really just to illustrate that even if you did, the program would be syntactically correct, but if we had said 'Repeat End', it would not be.

 

Repeat 0 times = A) Don't run any of the following actions at all?? When would this be used? B) Or does this mean "Run the following actions once, and then don't repeat them", for a total of one time through the actions?

Yes, it means do not run any actions. This would be used when you are writing and debugging your programs and you want to temporarily prevent a few actions from running.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37.2k
    • Total Posts
      372.5k
×
×
  • Create New...