forum.universal-devices.com

Welcome to UDI Forum
It is currently Tue May 21, 2013 10:51 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Learn about Variables
PostPosted: Thu Aug 09, 2012 6:49 pm 
Offline
Advanced

Joined: Sat Jul 07, 2012 10:31 am
Posts: 572
What is the best way for me to learn about variables? I have no programming experience and when I read the threads about variables I get very confused.

Thanks!


Top
 Profile  
 
 Post subject: Re: Learn about Variables
PostPosted: Thu Aug 09, 2012 7:09 pm 
Offline
Advanced

Joined: Sat Oct 03, 2009 8:07 am
Posts: 1765
variables are just numbers that are assigned names. [EDIT: It would have been better to say "variables are names that are assigned numbers" ] The numbers can change. . .thus they are "variable". There are 2 types in ISY.

Integer: These variables will not trigger a program.
State: These will trigger a program.

In other words, if the value of a variable changes, a state variable will cause a program to run if there is a reference to it in the "if" clause. An integer variable will not cause the program to run, but it will be checked if something else triggers it to run.

Example:
If state variable y = 1
and the time is 1pm
Then do this
Else do that

The above program will run every time y changes. So if some other program changes y at any time of day or night, the program runs and either "else" or "then" executes depending on if it is true or false. It will also run at 1pm and depending on if y is 1 or something else, either "then" or "else" executes.

If integer variable y = 2
and time is 1pm
The do this
Else do that

The above program will run at 1pm. . . and that is it. If at 1 pm the program runs and y happens to be 2, then the "then" clause executes. Otherwise, the "else" does. Besides 1pm, this program could be forced to run by a manual "run" command or another program that contains a "run" command which points to this program. But on it's own, it only runs at 1pm.


Last edited by apostolakisl on Fri Aug 10, 2012 12:58 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Learn about Variables
PostPosted: Fri Aug 10, 2012 4:25 am 
Offline
Advanced

Joined: Sat Jul 07, 2012 10:31 am
Posts: 572
That is a great explanation!

Now let me ask about this program...

Code:
If
        $Home.Sick is 0

Then
        $Home.Sick  = 1
        $Home.Sick Init To $Home.Sick

Else
        $Home.Sick Init To 0
        $Home.Sick Init To $Home.Sick


I know what $Home.Sick is 0 does/is but

-What does $Home.Sick Init To 0 do?

-What does $Home.Sick Init To $Home.Sick do?

Thanks!


Last edited by jmed999 on Fri Aug 10, 2012 9:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Learn about Variables
PostPosted: Fri Aug 10, 2012 9:10 am 
Offline
Intermediate

Joined: Tue Nov 29, 2011 7:16 am
Posts: 80
Nice explanation..


Thanks!

Brian


Top
 Profile  
 
 Post subject: Re: Learn about Variables
PostPosted: Fri Aug 10, 2012 12:56 pm 
Offline
Advanced

Joined: Sat Oct 03, 2009 8:07 am
Posts: 1765
jmed999 wrote:
That is a great explanation!

Now let me ask about this program...

Code:
If
        $Home.Sick is 0

Then
        $Home.Sick  = 1
        $Home.Sick Init To $Home.Sick

Else
        $Home.Sick Init To 0
        $Home.Sick Init To $Home.Sick




I know what $Home.Sick is 0 does/is but

-What does $Home.Sick Init To 0 do?

-What does $Home.Sick Init To $Home.Sick do?

Thanks!


Init is the initializing value of the variable. When ISY reboots, the value is set to the init value. So if you want it to hold steady through a power failure or reboot of any kind, you need to set the init value coincident with the working value.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group