Applescript (15)

1 Name: #!/usr/bin/anonymous : 2006-03-05 07:28 ID:xrLD1Ox8 This thread was merged from the former /code/ board. You can view the archive here.

Somebody else use it?

I really hate the language itself. It's probably the only language where it is easier to read scripts than to write them!

Applescript uses a natural language metaphor, which is a fancy way of saying that all the syntax is made up of arbitrary keywords, some of them actually being documented.

Here's an example of code lifted from the wp page about AS:

set pix to 72
set answer to text returned of (display dialog "Enter in the number of inches" default answer "1")
display dialog answer & "in = " & (answer * pix) & "px"

It is too hard for the non-programmer, because I really can't see how this way of using natural language could make coding easier, and it is also hard for normal coders, who are always trying to find out which magic keyword is used to abstract what they'd like to work with. It just is easier to read.

That's really too bad, because applescripts actually are quite powerful - you can automate a lot of nice things in OS X using them - I made a lot of scripts for my own use, I really like having the script menu and folder actions - but the language itself is too painful to use.

2 Name: Albright!LC/IWhc3yc : 2006-03-05 10:50 ID:Heaven

As a Mac user for the last nine years, I've given learning it a try a couple times, but I never get too far before I get frustrated and give up.

I've used Automator for a few things; that's a bit more logical to work with, but much less powerful, unfortunately.

3 Name: #!/usr/bin/anonymous : 2006-03-05 15:38 ID:Heaven

Supposedly the scripting architecture ("OSAScript", or something?) is language-independent, and you can install other languages to use instead of AppleScript. I haven't actually tried this, though.

4 Name: #!/usr/bin/anonymous : 2006-03-05 17:34 ID:29lgXtTm

5 Name: #!/usr/bin/anonymous : 2006-03-05 22:37 ID:piyCWJQY

>>3
Yeah, it'd be nicer to do this in JS, but could you keep the nice integration with the OS, like the script menu, folder actions, and could you trick apps that ask for the location of an AS to run a JS with minimal hackery? I know AppleScript does some weird compilation magic thing, does that means there's a way to write things in JS then have them work as if they were AS is OS X? I don't really know where to look for this info, I'd apppreciate it if somebody had a clear yes/no/somewhat answer

6 Name: #!/usr/bin/anonymous : 2006-03-05 22:39 ID:Heaven

> I've used Automator for a few things; that's a bit more logical to work with, but much less powerful, unfortunately.

It really, really needs conditional logic.

7 Name: Albright!LC/IWhc3yc : 2006-03-06 03:52 ID:3uz8itvA

>>5: Well, the official site ( http://www.latenightsw.com/freeware/JavaScriptOSA/index.html ) says

>JavaScript OSA provides full support for sending and receiving AppleEvents that leverages the AppleScript support found in the MacOS and the ever growing range of scriptable applications.

So it looks like it might just be a drop-in replacement for AppleScript that still provides the same functionality. I'll give it a more thorough look-over after work; this might be really cool.

8 Name: #!/usr/bin/anonymous : 2006-03-06 12:46 ID:Heaven

Automator is good for putting in a "Run Shell Script" action, and letting you do Perl scripting from inside the Finder, but not much else.

9 Name: #!/usr/bin/anonymous : 2006-04-12 04:39 ID:KXa9HDWK

I use applescript all the time. It's great for use with Obj. C applications (for talking to other apps.) Also good, as the above poster said, for running shell scripts etc.

10 Name: #!/usr/bin/anonymous : 2006-04-13 18:05 ID:7RBRFYpB

I have tried Javascript OSA. It can be used as a replacement for Applescript, but you still have to deal with Applescript limitations.

Would somebody know first-hand whether you can use PyObjC or RubyCocoa for small mac scripting, or is it only worth it for small apps?

11 Name: #!/usr/bin/anonymous : 2006-04-29 20:39 ID:RruUBGta

several ways to do the same thing, quirky non-uniform syntax, not small and consistent, imo it doesn't achieve true complete practicality in anything. scales very badly to very large projects. it's odd, but nonethless mediocre too. if you are interested in scripting languages, even if they are not perfect either, go for python and especially ruby; good balance between elegance/minimality and practicality. otherwise (if you like compiled would-be strong-type-checked languages ) go for java or .net if you don't need strict control in what happens with memory or precise performance features; otherwise, the "too-complex-but-very-effective" c++. good luck and tell us what you discover and think ;-)

12 Name: #!/usr/bin/anonymous : 2006-04-30 23:10 ID:Heaven

This kind of smells like what we used to have on the Amiga, starting from operating system version 2.04 onward. ARexx. The glue language that actually put applications together in a very reasonable way. Not quite Rexx as the poops at IBM imagined it.

Wonder why no one's come up with a working analogue to it yet.

13 Name: #!/usr/bin/anonymous : 2006-05-02 12:39 ID:f9oHo2/q

>>12

AppleScript is a working analogue to it. It's just that the syntax is horrible.

14 Name: #!/usr/bin/anonymous : 2006-07-18 22:13 ID:Heaven

>>13
Kind of what I meant.

15 Name: #!/usr/bin/anonymous : 2015-09-17 21:13 ID:DEDFZicZ

VORUDEMOTO

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: