Jump to content

adding subroutine programming construct


xd40

Recommended Posts

Posted

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.

Posted

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).

Posted

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

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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...

Posted
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

Guest
This topic is now closed to further replies.

×
×
  • Create New...