• 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: Feature request to solve a problematic AppleScript behavior with raw Apple Event codes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request to solve a problematic AppleScript behavior with raw Apple Event codes


  • Subject: Re: Feature request to solve a problematic AppleScript behavior with raw Apple Event codes
  • From: "Stockly, Ed" <email@hidden>
  • Date: Fri, 22 Oct 2010 16:58:02 -0500
  • Acceptlanguage: en-US
  • Thread-topic: Feature request to solve a problematic AppleScript behavior with raw Apple Event codes

On 10/22/10 1:27 PM, "Scott Babcock" <email@hidden> wrote:

>
> Script Debugger provides a way to *see* the Apple Event codes, but I don't
> think anyone provides the ability to prevent the AppleScript compiler from
> converting raw codes to "friendly" format.


Scott,

Here is your script from a compiled script editor window. It runs just fine
this way.

How is this different from what you were asking for?

-- »> BEGIN
tell «class capp» "System Events"
    set procRef to «class pcap» "Finder"
end tell
set refRecord to procRef as «class reco»
if ((«class form» of refRecord) is «constant ****name») then «event
sysodlog» "named"
-- «< END
-- The difficulty in this scenario is that AppleScript is too "helpful".
When it compiles «constant ****name», this raw code is converted to the text
"named".
-- »> BEGIN

tell «class capp» "System Events"
    set procRef to «class pcap» "Finder"
end tell
set refRecord to procRef as «class reco»

if ((«class form» of refRecord) is "named") then «event sysodlog» "named" --
compilation has rendered this line non-compile-able

-- «< END

-- The underlying code will be correct, but the source can no longer be
compiled - it's syntactically incorrect. There are a couple of ugly ways to
deal with this using strings:

-- »> BEGIN

property byName : «event sysodsct» "«constant ****name»" -- hack #1

tell «class capp» "System Events"
    set procRef to «class pcap» "Finder"
end tell
set refRecord to procRef as «class reco»

if ((«class form» of refRecord) is my byName) then «event sysodlog» "named
(hack #1)"
if (((«class form» of refRecord) as «class ctxt») is "named") then «event
sysodlog» "named (hack #2)"

-- «< END

 _______________________________________________
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: Apple Mail ToName Issue
  • Next by Date: Re: Can't drop onto my app
  • Previous by thread: RE: Feature request to solve a problematic AppleScript behavior with raw Apple Event codes
  • Next by thread: [ANN] New book on AppleScriptObjC
  • Index(es):
    • Date
    • Thread