Re: [Newbie] What's wrong with my code ?
Re: [Newbie] What's wrong with my code ?
- Subject: Re: [Newbie] What's wrong with my code ?
- From: has <email@hidden>
- Date: Wed, 28 Dec 2005 11:41:07 +0000
Eric Morand wrote:
>I attach the newly created menu item to the menu of the popup button but I can't access to its properties.
>
>In other words :
>
>set aMenuItem to make new menu item at the end of menu items of menu of encodersPopup with properties {title:"Test", enabled:true}
>display dialog (title of aMenuItem)
Because of the lazy way AS evaluates reference literals, the last line is actually telling AS to send the _reference_ 'title of menu item "Test" of...' to the 'display dialog' command. The 'display dialog' command doesn't know how to evaluate this reference, hence the error. You need to insert an explicit 'get' command to retrieve the referenced value, and pass the result of that:
display dialog (get title of aMenuItem)
It's another common gotcha: AS references are really simple first-class query objects, not the normal OO references you're used to. How these queries are constructed and when, where and how they're resolved isn't particularly obvious or well explained, and if you're coming from a conventional OO language then it's easy to form the wrong assumptions due to all the OO-like syntactic sugar.
Again, I'd suggest giving the appscript manual a quick skim as I've tried to disambiguate all these issues there. Even if you don't use Python it should provide some insight into how AppleScript operates as while the syntactic sugar is different the underlying principles are the same.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden