Jump to content

Programs that affect their own starting conditions


87squirrels

Recommended Posts

Posted

I know I've seen this posted somewhere, but now that I've run into it, can't find it...

 

I have two cases where the execution of a program changes one of the conditions required for the program to run, which causes the program to terminante prematurely.

 

The simple example is a program that I want to run if the garage door is opened and the driveway lights are not already on. Once the lights are turned on, the program terminates (and I want it to wait 10 minutes, then turn them off...). How can I decouple the program from the original conditions?

 

thanks,

-tom

Posted

One solution is to use two programs. Program 1 contains the If and runs Program 2 Then. That way when the If condition changes the reevaluation that occurs does not abort Program 2.

Posted

If program 2 continues running after 1 ends, then I'm all set. I'll set that up and test.

 

This suggests that programs started from other programs are asynchronous, i.e., the initiating program does not wait for completion of the new program before continuing. Is that correct?

Posted

87squirrels

 

That is correct. You will find lots of good information on Program execution in the UDI Wiki. The following is an excerpt from that Wiki ....

 

Statement Execution Order

 

Within the Then or Else clause of a program, statements are executed from top to bottom in the order in which they occur. When a statement calls another program, the called program begins executing, and the calling program immediately continues execution with the next statement in sequence--it does not wait for the called program to complete before continuing.

 

Lee

Guest
This topic is now closed to further replies.

  • Recently Browsing

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

  • Forum Statistics

    • Total Topics
      37k
    • Total Posts
      371.4k
×
×
  • Create New...