Trouble with an "and" Script

Having trouble finding an example of how to use an “and” in a script.

The Indigoserver is my home automation app that knows what the variables/groups are.

This is a mess I know but any help getting it working greatly appreciated.

tell application "IndigoServer"
	if the value of variable "sprk_button_paused" is equal to "on"     
and the value of variable "sprinklerRunningAny" is "true"
		execute group "Sprinkler - Pause Off"
	else
		if the value of variable "sprk_button_paused" is equal to ""
       and the value of variable "sprinklerRunningAny" is "true"
			
			execute group "Sprinkler - Pause On"
		end if
	end if
end tell

Thanks,

Carl

Hello.

I don’t have indigoserver, so I can just help you so much. I noted that your if statements missed the regular "then endings, I also cleaned it up a little bit, as it seems you don’t need an else clause embellishing the second if.

When it comes to the syntax of how you test for truth in your statements, value of variable “thisvar”, I am more unsecure as to if that is the right way to do it, I’d rather say if thisvar = value or thisvar is value. I advise you to consult any exampes you may have, I haven’t seen it like this before, and thinks this to maybe be something special for indigoServer.

tell application "IndigoServer"
   if the value of variable "sprk_button_paused" is equal to "on"  and the value of variable "sprinklerRunningAny" is "true" then
       execute group "Sprinkler - Pause Off"
   else if the value of variable "sprk_button_paused" is equal to "" and the value of variable "sprinklerRunningAny" is "true" then 
           execute group "Sprinkler - Pause On"
   end if
end tell

[b]equal
equals
equal to
is equal to

is[/b]

are official synonyms, Script Debugger changes the first three forms to the fourth

Another slightly optimization


tell application "IndigoServer"
	if value of variable "sprinklerRunningAny" is "true" then
		if value of variable "sprk_button_paused" is "on" then
			execute group "Sprinkler - Pause Off"
		else
			execute group "Sprinkler - Pause On"
		end if
	end if
end tell

Wow, works perfectly! Thanks a bunch.
I know I’ll get a lot of mileage out it.

Carl

But your end if’s they must be quite controversial Stefan! :wink:

By the way, I can’t remember ever having seen that value of variable “thisVar” before, is that offical AppleScript syntax, or is that from the terminology of indigoServer?

Of course. I never write end if, end tell etc. The Editor adds the respective terms automatically while compiling.
But the script didn’t compile because I don’t have IndigoServer

BTW: the Editor completes application for app and property for prop as well.

When SD asks me to choose the location of an app through the dialogbox, I just pick one from the list, and it compiles the script happily, without changing the name of the app in the tell block. :wink:
( I discovered that, when I compiled the indigoServer script.)

That trick worked only once, and the app I chose was a Microsoft Windows app. Now it complains over bad syntax in the value/variable clause in the if statement, and won’t let me compile at all.

Don’t forget ‘ref’ for ‘a reference to’. :slight_smile: I’ve always thought it a shame that ‘doc’ isn’t automatically expanded to ‘document’.

It’s the AppleScript compiler rather than the editor which does the completion. The abbreviations are also understood in text used with ‘run script’ or ‘osascript’.

Apparently, a ‘variable’ is an element with ‘name’ and ‘value’ properties in IndigoServer. I’ve answered a couple of Carl’s queries before. :slight_smile:

Hello.

prop for property is my favourite, and I miss one or two as well, I wonder if it will work to just enter the raw events, but I guess not.

By the way, I have dusted off my copy of FileMaker Pro, and that is an Ãœber cool app! -I have always thought of it as a clunky toy, but it isn’t, when you sit down and have a serious go with it. It has probably been too good looking for me to be taken seriously, having bad experiences, with such tools from before, but this is something better than MySql, and some crappy interface written in Java.

Edit

It has a stable sort algorithm when sorting tables, and it has been so fun, that I missed the match between Nigeria and Uruguay, I totally forgot about it. :o