Author Topic: Lesson #1.2 : Environment  (Read 3107 times)

0 Members and 1 Guest are viewing this topic.

Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Lesson #1.2 : Environment
« on: May 07, 2007, 10:17:34 PM »


1.2 Environment

The Editor:
Now that you have what you need, let’s see how everything works. Start by launching your Script Editor.

You will have to admit, it doesn’t look that complicated, mind you, I will agree with some that this “simplicity” is enough to give you “writer’s block”. 

First thing first, that window size is probably not suitable to you (It’s not for a lot of folks). Go ahead and resize it to a more usable format. Now, in order to have any new window open at this size, select Save as Default from the Window menu.
 

Script Editor window

Let’s talk about the interface now. As depleted as it looks, some of its items could use explaining:
  • At the top left of your window, lie the Record, Stop and Run button. While it is easy to infer what the Stop and Run button will do, the Record button however might not help you as much as it would seem.

    To illustrate this concept, we must first talk about the different types of Macintosh applications that are available to you:
    • First you have the regular “Non Scriptable” applications. These applications do not contain a dictionary accessible by AppleScript. We, as scripters, do not like those very much.
    • Next come the “Scriptable” applications. These applications do contain a dictionary but their content depends on the developer. In fact, this has to be the biggest “annoyance” with AS. There are little guidelines w/r to what the dictionary should contain. In essence you will have to “learn” the language used in each application you wish to script.
    • The next type contains “Recordable” applications. These applications as well as being able to receive “Apple Events” are able to return them as well. This allows you to see what events are triggered or necessary to accomplish a given task. Sadly, a very few applications are recordable and again it fall on the developer to integrate this feature into its app.
    • The last group contains the “Attachable” applications. These applications allow their users to “attach” or “link” scripts to its UI and, by the same token, extends its abilities.

    You can now see that the record button loses some of its promises knowing that just a few applications are recordable. That said, the Finder is recordable so you will be able to record many of your “filing” tasks. But, before you start jumping up and down, I must warn you that you will seldom be able to achieve a complete solution simply by recording your actions. For instance, the recorder will not be able to interpret any repeat loops, consider if statements, etc. At the very most, this will provide you with a workable shell for your workflows.
  • The next item in your window is the Compile button. Clicking on this will tell Script Editor to verify the syntax of any text entered in the “Code” area.
  • Next comes the Bundle Contents button. When enabled, this button will open a drawer displaying the contents of your script if was save as a bundle (we will go into them a shortly).
  • The main window is separated in two distinct areas. The topmost area contains (or will contain) your code.
  • The content of the bottom area is determined by the row of buttons directly below it:
    • Description: This will give you, of your users, some information about the script itself. As the scripter, YOU have to type in the desired information. This text will be displayed in the script’s “Startup Screen” if you check the appropriate boxes at save time (this will be covered a bit later). Please note that this field will accept styled text.
    • Results: Display the value of the last call of you script if there is anything to display.
    • Event Log: Displays a list of Apple Events and their returned values as they are happening. This one is very helpful when debugging your scripts.

I do not intend to go any deeper into this. For one thing, I have never used it. When I started scripting, the default Script Editor was much less capable and once I tried Script Debugger I never turned back. Aside form that, there's a pretty decent help document included in that application. That said, I would gladly answer the questions you might have about it.


What can I do with it?

Of course, you could fire up your Script Editor every times you need it, enter the desired code and run it on the spot. Once done, you could simply close that window without saving. The only nice part about it that this solution does not use much disk space. But let’s facing, we are all a tad lazy: Why else would we want to learn this stuff? In any case, you will often want to save your work for later use. A quick trip to the Save dialog will demonstrate that you have a couple of options available to you:


  • Script: This format will save script in a compiled form that will need to be interpreted by an AppleScript savvy application (Script Editor, AS Menu, Attachable application, etc.).
  • Application: This format will save your script in a stand-alone executable form.
  • Script Bundle: Same as with the “Script” format plus this format make a bundle of the resulting file.
  • Application Bundle: Same as with the “Application” format plus this format make a bundle of the resulting file.
  • Text: This format will save your script as text only. I personally used this format only when I needed to leave but couldn’t compile my script for XYZ reasons.

On top of this, you have a bunch of save options:
  • Line Endings: Only used when saving your script as Text.
  • Other options:
    • Run Only: Available in any format but Text. As its name suggest, this will prevent anyone from reading or editing your script. WARNING: this also applies to you so make sure to keep a restriction free copy somewhere else.
    • Startup Screen: Available only under the Application format. This will make the application display a dialog containing the script’s description (if any) as well as allowing the user to Quit or Run the script.
    • Stay Open: Available only under the Application format. By default, your script application will quit after the last line of code has been completed. By selecting Stay Open you are telling your script to wait for an explicit Quit command. Idling scripts are all Stay Open applications as they run a certain piece of code and lay “dormant” for a given time interval until the code is run again, and again.

Startup Screen


« Last Edit: May 08, 2007, 03:44:26 PM by Publi-Script »
Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Lesson #1.2 : Environment
« Reply #1 on: May 08, 2007, 03:22:49 AM »
Go ahead and resize it to a more usable format. Now, in order to have any new window open at this size, select Save as Default from the Window menu.

Great tip! Didn't know about it (on a 23" Cinema display, it helps!  ;D ).
Looking forward to reading next lesson! That's exciting!
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Re: Lesson #1.2 : Environment
« Reply #2 on: May 08, 2007, 06:12:36 AM »
As a user of this a side note to the above. Add your applications to the library for a quicker interface. You can open application dictionary's and start new scripts from this window too.

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Lesson #1.2 : Environment
« Reply #3 on: May 08, 2007, 07:25:38 AM »
As a user of this a side note to the above. Add your applications to the library for a quicker interface. You can open application dictionary's and start new scripts from this window too.
Waooh! Didn't know either! You seem to feel quite well what a newbie like me must know  ;D
Thanks, larsen67!
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =

Offline larsen67

  • Sr. Member
  • ****
  • Posts: 459
  • Karma: 10
  • Gender: Male
Re: Lesson #1.2 : Environment
« Reply #4 on: May 08, 2007, 08:03:08 AM »
Just something I found and not very long ago either. Was bugged by the fact that I started trying to script Quark yet I always was forced to browse to locate the application to open the dictionary. Could never work out why it did not appear in my default applications list. Im happy to have been of some use.

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Lesson #1.2 : Environment
« Reply #5 on: May 08, 2007, 09:02:50 AM »
I think this was fixed with v7 of Quark. I can see now Quark apps (4.11 through 7.2 + Help) in the default apps window.
But your trick is far quicker and much more interesting!  8)
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz • 10 Go 1066 MHz DDR3 • Mac OS 10.8.5 • QuarkXPress 9.5.4.1 • Adobe CS5 =

Offline Emma

  • Full Member
  • ***
  • Posts: 205
  • Karma: 9
Re: Lesson #1.2 : Environment
« Reply #6 on: May 08, 2007, 10:32:47 AM »
Library! Never spotted it, and always wondered why Quark had to be browsed for. It's great starting from scratch, because sometimes you've missed something really basic.
------------
Quark 6.5
OS X 10.4.8
G4