Re: Dumb First Time Apple Scripting question
Re: Dumb First Time Apple Scripting question
- Subject: Re: Dumb First Time Apple Scripting question
- From: Charles Bennett <email@hidden>
- Date: Wed, 03 Apr 2002 13:41:54 -0500
[munched]
Thanks for the answer. Between this and an off list answer from
Don Briggs (
http://homepage.mac.com/donbriggs )
I was able to fill in the missing conceptual part and my little
test scripting app is working. AppleScript is so cool!
The problem I had with the Apple doc's is almost backwards
from the usual complaint on this list. There is plenty
of documentation but not enough "education".
I kept seeing comments on the various lists about how easy adding scripting
was, but I couldn't get mine to work.
Now that I understand some of the basic's it IS easy ;-)
I'd also like to toss out a plug for Don's ScriptModeler
It really helped me figure out what the code should look like.
Thanks All.
BTW: Once I clean up my test app, I'll post the source with comments.
Perhaps I can pass the favor along and help someone else over the initial hump.
Chuck.
>
>
Here we see an interesting "feature" of the Cocoa scripting
>
system. As far as I can tell, whenever you define an attribute
>
that returns a non-basic object (i.e. not a string, number,
>
etc.), Cocoa doesn't treat it as a property of its parent but
>
rather as an element. So, while there is really only one
>
fooClass object, Cocoa treats it as being multiple elements.
>
Well, there aren't actually multiple objects (counting the
>
fooClasses will return 1), but it lists them as though there
>
could be.
>
>
> tell application "AppleScriptTest"
>
> tell fooClass
>
> copy 5 to fooVar
>
> end tell
>
> end tell
>
>
So, because if this, you have to access the object as fooClass 1
>
rather than just plain fooClass. Also, you usually use a set
>
command to set a property of an object. I think a copy might
>
work correctly, but you should get used to using set. So, in
>
short, try this script instead:
I'll use set from now on. The copy happened as I was following some
example in the AppleScript Language Guide, and thrashing around trying different
things to see if I could make the script work. When nothing works, it's hard to figure
out if the implementation or the script is wrong.
As a programmer, the script's verbosity seems very awkward to me. It's like a smalltalk
programming trying to grok cobol.
>
tell application "AppleScriptTest"
>
tell fooClass 1
>
set fooVar to 5
>
end tell
>
end tell
I would never have figured the fooClass 1 part out.. In my case, I only had one
so I'd never think that it had an index. ack.
>
--
>
Brian Webster
>
email@hidden
>
http://homepage.mac.com/bwebster
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
--
UPS Management software for OS X
http://www.powerguardian.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.