0

property slider : missing value if slider's integerValue = 5 then -- Do something end if

This code won't work. Any ideas why?

James
  • 213
  • 1
  • 3
  • 13
  • 1
    integerValue() returns a cocoa class. You always want to explicitly coerce numbers into an Applescript class if you're going to use them further in Applescript, to add an "as integer" when you get the value. – jweaks Nov 03 '14 at 16:31

1 Answers1

1

log class of slider's integerValue returns something called __NSCFNumber

log class of 5 returns <NSAppleEventDescriptor: 'long'>

Looks like Applescript does not automatically convert the values for you. To get it working a (strange looking) conversion will do it:

if slider's integerValue as integer = 5 then
    -- Do something
end if

Greetings, Michael / Hamburg

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18