How to use the Dictionary

Hi,

Understanding how the ‘dictionary’ works is key to grasping how to use applescript, as far as I can tell. But there does not seem to be an easy way to grasp how to understand the dictionary’s way of explaining things.

Take for example, the ‘make:Make a new element’ in the Standard Suite.

‘make’ (this is obvious)

‘new type class’ - where type class is ‘file’ or ‘folder’ or whatever. But where does one find out what variations of type class there are available?

‘at location reference’ - presumeably, in some folder or on the desktop (just another folder, I know). Can I no longer specify where on the desktop I want a file or folder to go?

‘with properties record’ - I know there is the property ‘name:’, but are there any other properties and where I go to find what these other properties are?

Just one other matter with regard to the ‘data size’ command.
I have a file that is 192 KB when I do a Get Info. But when I run a ‘data size’ in applescript I get 428 (presumeably in bytes). I don’t understand this!

It seems to me, understanding how to use dictionaries is not so easy. I can’t seem to grasp how to interpret it, how it all fits together so that one can create sensible applescript programs that work!

Any help gratefully accepted. javascript:emoticon(‘:D’)

Michael.

  • Teorically, you can use “make” to make Finder’s supported “objects”, which are “classes”. For instance, files, folders, internet locations, Finder windows and so on… You’ll find that you can’t “make” anything (eg, a clipping window or an application process)
  • “at” is a location. If a file, you must place it somewhere in your disk. If a Finder window, you don’t need make it at any specific place (though you can alther the x-y coordinates, but this is not a location but a position, a property inherited from the window class)
  • “with properties”. If you make a file, take a look to the class “file”, and you can adjust anything which is not labeled “[r/o]” (read/only): name, file type, label index… And you’ll find also this is not allways true. Though you think you can manipulate the “icon”, you can’t. Just investigate.
  • “data size”. Buggy, as far as I know. Some commands-classes-properties in Finder’s dictionary simply don’t work.
    Lots of dictionaries will include a “Required Suite”. This suite should add support to four basic commands: run, print, quit, open. Oftenly they include “save”, “exists” and other commands, and implement the “required” commands in the “Standard Suite”. They may work or NOT. Some times developers make a copy-paste of existing dictionaries, but all commands are not fully implemented in their apps.
    Some time ago you could find even something similar to “Miscellaneous Odds and Ends Suite”, including a command called “SetTellTarget” with description “Makes an object the “focus” of AppleEvents”. I think this command, implemented in a bunch of dictionaries, never worked. This is an example of what you can find in a dictionary. Lots of things which can work or not as you expect.
    Another example with the mentioned “save” command (if it works fine at all in the targetted app), is the parameter “in”, which can accept an alias, text path, reference, even a POSIX path. Perhaps you pass an alias and it doesn’t work. Perhaps you must create first the file, then pass the alias, perhaps you can pass what you wish and it works fine…
    Every application has its own rules.

thanks for your reply, jj.

I’m wondering if I have a ‘funny’ dictionary.
When I look up ‘file’ in my dictionary if can’t see ‘name’ or ‘label index’.
I see …“Inheritance”,“file type”,“creator type”,“stationery”,“product version” and"version". Am I looking in the wrong area?

Michael

inheritance is a major part of reading the dictionary.

item [r/o] – inherits some of its properties from the item class

You then look under class ‘item’ for more properties of ‘File’. Not all the properties may pertain to the ‘file’ class. Most properties that do will be obvious.

gl,

Yes, I understand now.

When I go to ‘item’, I do see the other properties.

Presumeably, if there is no ‘inheritance’, then I have reached the lowest level?
No need to reply to this, unless I’m wrong in my understanding at this point.

Thanks for you help gl.

Michael