Re: Object types
Re: Object types
- Subject: Re: Object types
- From: has <email@hidden>
- Date: Tue, 16 Jul 2002 22:05:14 +0100
Frank Renner wrote:
>
set the source_folder to choose folder
>
set item_list to list folder source_folder
>
>
works fine and
>
>
set the source_folder to folder "New Folder"
>
set item_list to list folder source_folder
>
>
does not. It4s both folders or what?
For starters, try narrowing down the above to identify the exact point of
failure (e.g. by running in a debugger/adding log statements to record
values in the event log/commenting out the lines you don't want to test).
Compare the results generated by each line of the working script with the
equivalent line in the non-working script. Usually a good starting point to
the problem is identifying _precisely_ where the differences/errors lie.
You're correct in pointing out that dictionaries and documentation
frequently leave a lot to be desired. Hopefully things can only improve.
As for understanding Finder scripting, you need to understand what an
object model is, and how the objects you see on the AS side map to the
file/folder/disk objects you see in the filesystem. Until/unless you grasp
stuff like tree structures and containment, you're basically thrashing
around in the dark. I sometimes think there's an underlying fear of talking
Big Theory Stuff when it comes to AS - a worry that it's scare off the
newbies. I think the real problem is a failure to describe these concepts
in neutral, non-language-centric terms that map it to things that people
already understand.
After all, anyone who can drag-and-drop files and folders in a GUI is
already familiar with all the high-level concepts they need to understand
how Finder scripting fundamentally works: the only thing is they don't
realise it yet. And then along comes the literature and buries all this
understanding under a mountain of futzy little implementation details,
giving completely the wrong impression about what's really important and
what's not.
On top of which, it's easy to confuse AppleScript's native way of referring
to files/folders with the Finder's (not least because there's some
carelessness in their naming: homonyns everywhere). Learn what
AppleScript's "alias"/"file" data types and how they work, and don't
confuse that with the Finder's own system for referring to files/folders as
object references ("object X within object Y within object Z").
AS has a tendency for inviting users to make assumptions about the way they
think it works: try to resist this urge. If you've already got prior
programming experience, get yourself a copy of the AppleScript Language
Guide or something, and refer to that when translating your existing
knowledge into "AppleScript-Think".
has </unfocussed, ill-directed rant>
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.