Two Docommands in a row fail, macro works...

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

Two Docommands in a row fail, macro works...

Postby edentel » Sun Feb 13, 2011 10:20 am

Man I'm having fun moving things totally to i-devices! In the process I'm pulling my hair out. After an hour of playing around it appears that you cannot have two docommands in a row, ie:

function Zone(zNum) {
doCommand("SetVariableFast|CurrentTempZone~" + zNum);
switch(zNum)
{
case '':
doCommand("SetVariableFast|CurrentTempZoneName~Upstairs");

With this code only the second doCommand executes. I've verified that within the Event Log. After futzing around I shifted to:

function Zone(zNum) {
doCommand("SetVariable|CurrentTempZone~" + zNum);
switch(zNum)
{
case '':
doCommand('Macro|SetVariableFast|CurrentTempZone~26!SetVariableFast|CurrentTempZoneName~Downstairs');

aaaaaaaand everything works fine. Am I right in my takeaway that two doCommands in a row fail and you must use a Macro?

Is there an intentional/unintentional reason or logic behind this that anyone is aware of?

Thanks and hope it helps some other javascript newb!
-Ed

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

Re: Two Docommands in a row fail, macro works...

Postby CinemarDave » Sun Feb 13, 2011 11:29 am

You are correct in that you cannot string multiple doCommands in a row. The reason for this is not really intentional but a by product of how doCommand works. Every call to doCommand ends up calling UpdateVariables to refresh the server variables. Since both routines use the same xml object to talk to the server the callback routines get reset. This results in losing the second doCommand. There's probably a way to engineer around this but for now build a macro string and execute the macro.

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

Re: Two Docommands in a row fail, macro works...

Postby edentel » Sun Feb 13, 2011 11:32 am

Thanks! I appreciate the info, at least it makes sense now.


Return to “MainLobby on iPhone, iPod Touch”

Who is online

Users browsing this forum: No registered users and 1 guest