Is this possible? ≤ & ≥

So I’m wondering what I’m doing wrong to get this. It doesn’t want to compile. Is there another route?
Thanks!


if timeOfTrack2 ≥ 15 & ≤ 30 then
end if

You have to be verbose:


if timeOfTrack2 ≥ 15 and timeOfTrack2 ≤ 30 then
end if

oh, thats funny. kinda silly that it has to be like that but I didn’t come up with the language. :slight_smile:
thanks a bunch Craig!

Actually not silly. AND is a boolean operator that expects to find (true or false) AND (true or false); i.e. both sides have to be boolean. If you say A = B & A = C, that works. But if you say tofT ≥ 15 & ≤ 30, this is evaluated as (tofT ≥ 15) AND (≤ 30) so the second term isn’t a boolean, it doesn’t make sense.

so then, in theory, this should function the same?


if (timeOfTrack1 + timeOfTrack2 ≥ 15) & (timeOfTrack1 + timeOfTrack2 ≤ 30) then

(I’m not able to test it yet.) :frowning:
and sorry, i didnt mean silly as in a bad way. i just find it interesting that “&” doesn’t equal “and” but that makes sense.

No, not at all, don’t mix up the operators.

& is the concatenation operator, used only for strings, lists and records, the result is a string, list or record.
+ is the addition operator, used only for numbers. The result is a number
and is the logical and operator, used only for boolean values (true or false). The result is boolean

the class of the operands must match the operator.
If not, AppleScript tries to coerce the values to the needed class, for example

"1" + "2"

the strings “1” and “2” will be coerced to an integer and then added. The result is an integer 3.
If the coercion fails, an error will be thrown.

In this example

"1" & "2"

the result is “12” (a string, not a number), while

1 & 2

results is a list {1, 2}, because string concatenation works only, if the second operator is a string

In some languages && is an AND, but AppleScript isn’t one of them.

ok, that makes much more sense. its like getting your tenses correct, right? something like, “I went to the store and get some milk.” it makes more sense to say, “I went to the store and got some milk.”

thanks a ton and any more insight is greatly appreciated.