xd40 Posted July 17, 2010 Posted July 17, 2010 Have you guys given any consideration to adding a programming construct for a subroutine call to the ISY? This would be a very powerful addition which would allow us to create more modular code.
Michel Kohanim Posted July 18, 2010 Posted July 18, 2010 Hello xd40, Yes. In the meantime, you can actually call other programs from within your current program. You can even call the If, Then, or Else segments of all other programs. With kind regards, Michel
xd40 Posted July 18, 2010 Author Posted July 18, 2010 you said "call", I suspect you meant "run" as that's the only option I see. But the distinction is that if I "run" the other program from a program, it DOES NOT return to the calling program. It originally took me hours to figure out why my code wasn't working until I understood that the execution does not return from a "run" (that was a year or so ago).
Michel Kohanim Posted July 18, 2010 Posted July 18, 2010 Hello xd40, Perhaps we are not talking about the same thing? You can call as many programs (run if/then/else) from the main program. The only time the execution stops is IF the condition of the calling program has been invalidated. With kind regards, Michel
xd40 Posted July 18, 2010 Author Posted July 18, 2010 pseudo code example: Program1 do thing x do thing y run program2 do thing z <-- this never runs Program2 do thing a do thing b
Michel Kohanim Posted July 18, 2010 Posted July 18, 2010 xd40, Just to be sure, I created a test program which calls 3 different programs each one of which send an email to a different recipient: If Status 'adf / blah blah' is On Then Run Program 'email 1' (Then Path) Run Program 'email 2' (Then Path) Run Program 'email 3' (Then Path) Else - No Actions - (To add one, press 'Action') This works as expected. As I mentioned, unless the condition causes the program to stop, all programs should be called in sequence. i.e if the status of the lamp adf/blah blah becomes off during the execution then everything stops. With kind regards, Michel pseudo code example: Program1 do thing x do thing y run program2 do thing z Program2 do thing a do thing b
xd40 Posted July 19, 2010 Author Posted July 19, 2010 Interesting, that has not been my experience. Maybe there was a bug in one of the beta versions I was recently using. I guess the next time I'm tweaking my programs I'll try this again.
Goose66 Posted July 19, 2010 Posted July 19, 2010 Question: Does the execution of the calling program wait for completion of the runned program? Also, this is another opportunity to promote my wish for scripts kicked off by trigger conditions.
Michel Kohanim Posted July 19, 2010 Posted July 19, 2010 Hello kingwr, The execution ends as soon as the condition of the calling program becomes false. With kind regards, Michel
xd40 Posted July 20, 2010 Author Posted July 20, 2010 The execution ends as soon as the condition of the calling program becomes false. That's interesting. Nothing like making the outcome of a "function call" non-deterministic based on some external event that you've already tested against. I guess that makes sense in somebody's world--just not mine. I have a computer science degree over 25 years programming experience and I have to say that the home automation world has a very odd concept of what a programming language should look like. I should know by now that when your "programming" is constrained by a menu driven "program builder" that there are going to be significant limitations of that "language". i.e.: - abnormal program flow - no case statements - no arrays - no type conversion - no function calls - no math functions - oh, and no variables...??? Why don't you guys consider embedding a LUA interpreter so we can write some of the functionality we need for ourselves? I still have a 10 year old X10 controller running all of my lawn sprinkler programs because the programs are too complex to implement on the ISY...
Sub-Routine Posted July 20, 2010 Posted July 20, 2010 The execution ends as soon as the condition of the calling program becomes false. The execution of the calling program quits but any called program will continue unless it is explicitly Stopped. This can be done using the Else actions. Rand
Recommended Posts