Jump to content
C4 Forums | Control4

multiple if statements due to multiple functions


yelkenli

Recommended Posts

I have a motion detector that controls lights with a simple script: when sensor senses motion, if time is between x and y hours, activate lighting scene. 

I would also like to have the motion detector send me a push notification as follows: when motion sensor senses motion, if 'Out-of-House' is true, send push notification. 

My problems are several fold:

I am not able to get action statements to nest.  usually, these are indented under an if statement.  I can drag the action statement to the if statement, get a yellow highlight, and get either a down arrow or right arrow.  However, no indent. 

Second, the support technicians don't support Composer (the one I talked to), and was unsure if multiple conditional statements are allowed in scripts. 

I would expect something like this:

When sensor senses motion

  if time is between x and y hours

        activate lighting scene. 

  if 'Out-of-House' is true

       send push notification. 

 

Ignoring the inability to nest, would this operate such that it evaluates the first if statement and takes action if appropriate, and then go to the next if statement and take action if appropriate?

Or is it illegal to have multiple if statements?

 

Any ideas on the nesting issue?  are there keyboard commands, like holding the option key, etc, that would make the nest?

 

Any recommendations are appreciated. 

Link to comment
Share on other sites


So for someone on 2.9.1, the following applies:

Right arrow should be nesting...

Yes, you can have multiple ifs.  They can be nested or not. If not nested, then they will happen one after the other unless you use a stop statement in which case if the execution gets to the stop statement (due to the relevant condition being true) then no further lines of code will be executed.

Link to comment
Share on other sites

  • 3 years later...

For anyone else struggling getting Commands to nest below Conditionals, there is a trick to doing this.

You have to drag the Command Statement (Green Arrow) to the Blue Question Mark *ICON*. You must drag to the ICON itself and not the text beside the icon. (If you drag the Command Statement to the text beside the Blue Question Mark Icon, you will not get the "right arrow overlay" nest option. Dragging Commands to the Conditional text gives only the option to reorder the Command above/below the Conditional. This is very bad UI design by Control4 in Composer.)

5ac6db09901e8_ScreenShot2018-04-05at7_18

Link to comment
Share on other sites

6 hours ago, WhyPhy said:

For anyone else struggling getting Commands to nest below Conditionals, there is a trick to doing this.

You have to drag the Command Statement (Green Arrow) to the Blue Question Mark *ICON*. You must drag to the ICON itself and not the text beside the icon. (If you drag the Command Statement to the text beside the Blue Question Mark Icon, you will not get the "right arrow overlay" nest option. Dragging Commands to the Conditional text gives only the option to reorder the Command above/below the Conditional. This is very bad UI design by Control4 in Composer.)

5ac6db09901e8_ScreenShot2018-04-05at7_18

So... this works exactly as designed and as documented in the user manual... 

Link to comment
Share on other sites

I'm surprised by the snarky replies. This question has been asked multiple times in multiple threads. None of those threads returned in my search provided this information, so I decided to document it for the next person searching for the solution. I don't see why this is deserving of contempt.

As far as how this feature could be better implemented, literally any other approach would likely be better. Dragging an object to an unmarked UI target at the far left side to get that object to nest under the target (and toward the right) goes against pretty much every basic rule of UI design. A simple alternative solution would be to have indent/outdent UI buttons appear beside a command when it's selected. Another option would be to nest the command when it's dropped directly on top of the target, but also show a horizontal divider target between the rows when dragging slightly above or slightly below an existing row (the way row re-ordering is displayed in pretty much every spreadsheet.)

Also, it's somewhat ironic that this is the same screen that pops up an "Expression Builder" warning, and also that the expression builder has a dedicated UI element just for re-enable the pop-up warning after it's been disabled. The "drag left to nest right" function is less obvious than the Expression Builder.

Link to comment
Share on other sites

30 minutes ago, WhyPhy said:

None of those threads returned in my search provided this information,

Yet I know I've stated it several times, and so have others.

Maybe try indenting the search criteria 😉

30 minutes ago, WhyPhy said:

unmarked UI target

? not clear enough for you I guess

33 minutes ago, WhyPhy said:

Another option would be to nest the command when it's dropped directly on top of the target

But, this is exactly what you do. The target is the IF, not the condition/detail of the IF
.

32 minutes ago, WhyPhy said:

A simple alternative solution would be to have indent/outdent UI buttons appear beside a command when it's selected

Would fail the moment you're doing multiple IF statements in a line

 

34 minutes ago, WhyPhy said:

As far as how this feature could be better implemented, literally any other approach would likely be better

Time to apply for a job then.

 

❤️

Link to comment
Share on other sites

You don't seem to be interested in a constructive discussion about how this functionality could possibly be improved, but rather defending the existing confusing functionality that you and others have apparently had to explain numerous times. Unfortunately, Google has not yet adjusted their algorithm to prioritize results based on your documentation of this functionality. The other 4 top Google results, which are all on this forum, are still awaiting inclusion of this insight. I fear I should not further my participation.

Link to comment
Share on other sites

21 minutes ago, WhyPhy said:

You don't seem to be interested in a constructive discussion about how this functionality could possibly be improved, but rather defending the existing confusing functionality that you and others have apparently had to explain numerous times. Unfortunately, Google has not yet adjusted their algorithm to prioritize results based on your documentation of this functionality. The other 4 top Google results, which are all on this forum, are still awaiting inclusion of this insight. I fear I should not further my participation.

I spent a few years meeting with hundreds of dealers and thousands of programmers and not once had this complaint, and I was the guy programmers would complain to so if it was going to come up it would have.  Sure, guys forgot to nest on the if statement, but nobody every complained about how that process happened.  Not a knock on you or your opinion on the matter, just saying as a whole people don't seem to think it's an issue, so change is highly unlikely. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.