Variables within Macro not updating...

Discussions about Mainlobby running on Apple mobile devices.
edentel
Member
Member
Posts: 93
Joined: Sat Mar 19, 2005 2:17 pm
Contact:

Variables within Macro not updating...

Postby edentel » Sun Feb 13, 2011 11:11 pm

Sooooo last stumbling block for the weekend. I'm working through modifying the Thermostat screen to support and ISY handled Insteon Thermostat. I've replace the temperature changes lines with in-line macros. The macro runs, I see the variable update, however the updated value isn't carried from one step of the macro to the next.

Macro:
<span onclick="doCommand('Macro|mlmath|Add~NSP~{{mlisy_22_heat_setpoint}}~1!MLISY|mlisy_22~SetHeatSetpoint~{{NSP}}');

Event log:
Macro|mlmath|Subtract~NSP~70~1!MLISY|mlisy_22~SetHeatSetpoint~70
mlmath|Subtract~NSP~70~1
MLISY|mlisy_22~SetHeatSetpoint~70

Looking at the server variables I see NSP actually decrement to 69. For some reason it isn't updating from the subtraction to actual setting in the next part of the macro.

Any suggestions would be really appreciated!

Thanks,
-Ed

User avatar
CinemarDave
Site Admin
Site Admin
Posts: 10535
Joined: Fri Feb 07, 2003 8:56 am
Location: Planet Earth
Contact:

Re: Variables within Macro not updating...

Postby CinemarDave » Mon Feb 14, 2011 10:46 am

Server variables are resolved on page load. If you want to preserve them in your macros so their current value is not lost change

<span onclick="doCommand('Macro|mlmath|Add~NSP~{{mlisy_22_heat_setpoint}}~1!MLISY|mlisy_22~SetHeatSetpoint~{{NSP}}');

to
<span onclick="doCommand('Macro|mlmath|Add~NSP~{'+'{mlisy_22_heat_setpoint}'+'}~1!MLISY|mlisy_22~SetHeatSetpoint~{'+'{NSP}'+'}');

That way the variables will be interpreted in MLServer when the command gets executed.

edentel
Member
Member
Posts: 93
Joined: Sat Mar 19, 2005 2:17 pm
Contact:

Re: Variables within Macro not updating...

Postby edentel » Mon Feb 14, 2011 11:16 am

Thanks as always!


Return to “MainLobby on iPhone, iPod Touch”

Who is online

Users browsing this forum: No registered users and 1 guest