• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting class-name: Error when converting to string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting class-name: Error when converting to string


  • Subject: Re: Getting class-name: Error when converting to string
  • From: Shane Stanley <email@hidden>
  • Date: Mon, 5 Jun 2017 21:02:55 +1000


On 29 May 2017, at 2:11 am, email@hidden wrote:

I’ve a function that takes an object as parameter. To execute specific code based on the class-name, I’ve written this (example) script:
  1. set windowClass to class of theWindow
    if (windowClass is equal to "NSWindow") then
    display dialog "continue"
    end if

The problem is that it never reaches the dialog, because windowClass is not a string and furthermore not comparable, so I need to convert the variable to a string:
  1. set windowClass to (class of theWindow) as string
    if (windowClass is equal to "NSWindow") then
    display dialog "continue"
    end if

Try:

set windowClass to class of theWindow
if (windowClass is current application's NSWindow) then
display dialog "continue"
end if

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: 10.12.5 at work.
  • Next by Date: Finder preferences
  • Previous by thread: Re: 10.12.5 at work.
  • Next by thread: Finder preferences
  • Index(es):
    • Date
    • Thread