Re: AppleScriptObjC oddity
Re: AppleScriptObjC oddity
- Subject: Re: AppleScriptObjC oddity
- From: Steve Mills <email@hidden>
- Date: Sun, 12 Jul 2015 22:41:15 -0500
On Jul 12, 2015, at 21:48:26, Chris Page <email@hidden> wrote:
>
> Do you have more than one display? AppleScript indexes are one-based, but Objective-C's are zero-based. So, "objectAtIndex:1" is asking for the second screen, not the first one. There are two potential problems:
2 screens. I was after the non-main screen, so 1 was the correct 0-based index.
> While I'm at it, I'd like to make some other comments about the code:
>
> 1. Since the script doesn't use scripting additions, there's no reason to 'use scripting additions'. One of the goals of "use" is to add more structure and explicitness to the otherwise very dynamic AppleScript language, and part of this is being concise and not "use"ing things unless you actually need them. (I understand if this is an excerpt from a larger script that does use additions, but I thought this was a good opportunity to mention this.)
>
> 2. "screens" and "frame" are properties, not functions, so you shouldn't use "()" with them. Although it may currently work, it is superfluous and the exact meaning of using parenthesis after a property name may change in the future. (e.g., it should probably mean instead “get the property, whose value is a function, then call that function", just as it does when sending the message to an AppleScript object that has a property whose value is a handler.)
I got the code from Shane Stanley. He may have just grabbed some code he had laying around - not sure. I just used it mostly as-is. :)
If look later into the thread, you’ll see that the bug seems to be caused by running the script from DragThing. It works fine when running from other apps or as an applet.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
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