Variables are slightly controversial in the sense that they are powerful but often can be ineffective if not properly implemented.
I've decided to create this small tutorial to help some beginners and DIY's learn simple techniques that are effective in certain situations.
The beautiful thing about variables, is there is no "one way" to use or implement them, which makes them a very powerful tool to use. I highly recommend using them.
The first demonstration I will show is using variables to correct themselves and if that cant be done, then the pressing of a single button to correct the problem. For example: AT&T Uverse has a discrete on, but not a discrete off. In addition to not having a discrete off... receiving the OFF IR command isn't always 100% reliable. I often find the variable out of wack.
I have code that looks like this on the power button that turns off cable in the Family Room:

The problem is that when using a button such as "System Off" or "Play Playstation" that performs many operations, for whatever reason... if the cable box isn't actually turned off, the remote control still thinks it's off because the power variable is set to false. This could mess things up for other operations I want the remote to perform.
Here is how I fixed the problem.
First I set up a discrete self correcting power toggle.

The code looks like this:

What makes this technique better, is if in the event that the power doesn't turn off, I can use the discrete on operation with the power toggle to turn the cable box off and set the "fr_cable_power_off" variable to the right state. If the cable box is on and the remote thinks it's off, one press of the toggle should turn tell the remote that the cable box is on, and a second press will turn the box off and set the "off" variable to true.
Now even though this corrects the situation. You can't look at the state of the variable visibly and see whether the remote thinks it's on or off. For this reason, I've set up an indicator to tell me visibly whether the box is on or off. I used an additional variable to help me keep other variables in check.
If the remote thinks the box is on:

If the remote thinks the box is off:

Setting up an indicator is easy. Export a green button, shrink it to about 20 pixels, and do the same for a red button. Create a variable called "cable_power_on" and set it to initial value "false". Import the red "off" button you created, and for its pressed state, import the green "on" button you created.
It should look similar to this when finished:

Next select your "cable_power_on" variable in this drop down box:

Now, when your cable power is turned on and your "cable_power_on" variable is set to true, you power indicator will be green. When the power is turned off and the variable is set to false, it will show red.
If you don't have a discrete on or off, simply set the macro code on the indicator graphic such that,
when pressed, it
swaps the value of the variables to the correct state of the device.
The second demonstration I will show is how to creatively use variables to perform multiple actions from different devices throughout the remote from one central device on the remote. Example: This is my bedroom device that hosts buttons to individual room devices.

From this location, I have hard buttons on the bottom that perform all the macros to do those activities. The icon buttons jumps to those individual devices. As you can see, I have multiple devices but I dont have multiple versions of the guide button. But, with the power and correct implementation of variables... I can make these buttons sing.
Example: this can be done a few ways, but I chose to do it through the main device I use in the room which is the Marantz SR8002 stereo receiver.
I like to call this the "one button does wonders" technique.The button I'll demonstrate is the "GUIDE" hard button in this case.
This is what I want to do, when I'm in the bedroom device, I want to be able to control the Marantz hard buttons as well as the Epson 8500UB Projector hard buttons.
Variables used:
"control_marants", and "control_epson"
These variables control the visible indicator.
Very simply, the if/else statements and "Punch Through" does the rest of the work.
Procedure:First i have created a transparent graphic, and 2 other graphics to use called "EPSON" and "MARANTS":
Transparent...

Epson...

Marantz...

Next, I set them up to look like this: Setting their before graphic to transparent and their after graphic to the picture.

And, I place them on top of one another like this:

Next, from within the Marantz device, I have programed my guide button with this code:

The guide button code works such that:
On long press, switch between (toggle), Marantz indicator "true" and Epson indicator "true".
This operation shows and switches the indicator on screen.On short press, if epson control indicator is true then press the guide button for the Epson projector, or else if the marantz control indicator is true then press the guide button for the Marantz stereo receiver.
The initial value for epson control is true, so the guide button and indicator are default.
After coding, I Punch Trough this hard button to be used on the Bedroom device:
In action: this is what happens.
Long press toggles control.
When epson control is true, my Bedroom device shows:

On short press: the guide pops up...

On long press: the toggle switches to Marantz:

On short press: the guide pops up...

The power of variables is enormous as you can see. But, as I said at the beginning of this demonstration, if implemented incorrectly... it can be ineffective in your set up.
I hope this thread proves helpful to some of you beginners and do it yourselfers. PM and post if you have any questions or need something further explained.
Last edited by mistachy on May 29, 2010 22:39.