Jump to content

Reinitialize a variable


lgilsenberg

Recommended Posts

As I getting into writing more programs, I am finding that there is a need to temporarily store the initial value of a variable into a temp variable.  Then after modification of the variable, I finally want to restore it to its original value.  If we had a way to use the init value to restore the variable then we have an elegant way to see the variable list and reset values in one place and cut down on storing and restoring variable values.

For example:  

My motion sensor programs have a default timeout length of 10 minutes.  When I am reading or watching TV, the timeout is too short since there is no movement for over 10 minutes.  Today, I have a program that gets its new timeout value from Amazon Alexa and sets that up as the new timeout in ISY for the motion sensor.  I do want to reset the timeout value when I am finished my motionless activity or a new day starts or I leave the room for a period greater than the Alexa defined timeout value.  In these cases, I would love a command:

$Motion_Timeout REINIT to $Motion_Timeout

This command would set the $Motion_Timeout to the init value defined in the Variable table.  We would be able to see all variable initial values in one place and have an easy way to reset either one or many in a simple command.

Instead of 

$Motion_Hold = $Motion_Timeout

do some work and then restore it with

$Motion_Timeout = $Motion Hold

@Michel Kohanim Thank you for considering this 

Link to comment

I also have wished that there was a way to reset a variable to its init value.    The current value of the variable can be stored as the init value, but there is no method to do the reverse, that is move the init value to the current value.   If this existed I could save around a dozen variables.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...