KevinCork KevinCork - 29 days ago 10
AppleScript Question

Applescript if equal to, equal to, equal to

I try to do do a script to set a variable (e.g set matchornotmatch to match) if all the variable are equal.

set value1 to "FR"
set value2 to "FR"
set value3 to "FR"
set value4 to "FR"

set matchornotmatch to "no match"

if value1 is equal to (value2 is equal to (value3 is equal to value4)) then
set matchornomatch to "MATCH"
end if


if not return value1 = value2 = value3 but is not equal value4 (if possible)

Answer

A series of If, else if, else statements should do the trick:

set value1 to "FR"
set value2 to "FR"
set value3 to "FR"
set value4 to "FR"

set matchornotmatch to ""

if (value1 = value2) and (value1 = value3) and (value1 = value4) then
    set matchornotmatch to "MATCH"
else if (value1 = value2) and (value1 = value3) then
    set matchornotmatch to "partial match"
else
    set matchornotmatch to "no match"
end if

return matchornotmatch