• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)


  • Subject: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
  • From: Michael Terry <email@hidden>
  • Date: Sun, 11 Apr 2004 13:42:49 -0700

Thanks very much for the commentary, Nigel.

On Apr 11, 2004, at 8:17 AM, Nigel Garvey wrote:

Michael Terry wrote on Fri, 9 Apr 2004 18:15:26 -0700:

In the case of:

set contents of {a, b} to {"hello", "there"}

... the compiler doesn't recognise this as a setting by list. It sees an
instruction to apply the 'contents of' code to {a, b} and to set the
result to {"hello", "there"}. At run time, the 'contents of' code returns
a *list* {3, 4}, which obviously can't be set to anything.

Well, that's what does happen, but wouldn't it have been logical for AS to recognize it the other way? By comparison:

set x to missing value
set y to a reference to x
get y's contents
--> missing value

...but 'set' still recognizes that here:

set x to missing value
set y to a reference to x
set y's contents to anything

...you're not trying to set 'missing value' to 'anything'.

Even if it did work, though, it would only be useful if applications could return property references. Have you ever seen a program that allowed this:

tell app "Finder" to get name of files 1 thru 2 of f as reference
--> {name of document file "hello there" of folder "Temporary Items" of startup disk of application "Finder", name of document file "hellother" of folder "Temporary Items" of startup disk of application "Finder"}

Actually, given that the main bottleneck in using a list of references like this would be Apple event throughput, the discussion above is a trifle academic--might as well loop through the list. Don't let that stop it, though--many an academic discussion on this list has inspired a practical solution in my code.

tell application "Finder"
set name of first file of folders 1 thru 2 of f to {"hello", "there"}
end tell

That seems like the best way to do it to me. Is it dumb for some
reason? Would it be bad to extend 'set' this way? If so, is there a
suggested command name to do this sort of thing?

I'm guessing that it would be *possible* for an application to have this
ability, but your syntax would be very confusing. It's basically saying:
'set each name to the list {"hello", "there"}.' It might be better for an
app to implement some sort of 'distribute' command:

tell application "Finder"
distribute {"hello", "there"} to name of first file of folders 1 thru
2 of f
end

I'm considering it as a matter of context. First, application class properties usually aren't lists. Second, even in the cases where they are, the scripter, developer, and the 'set' command itself would, in most applications, be able to tell by context what to do. Now, some people don't like too much context-based behavior, but how much is too much? I happen to like context, and AppleScript seems pretty context sensitive.

On the other hand, your suggestion is great, and I get the impression that people already have a hard enough time figuring out how to script applications with AppleScript. Maybe its best not to introduce any more easter egg features. I might like to think of a shorter, Anglo-Saxon word for the command, though...

Mike
_______________________________________________
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.


References: 
 >Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb) (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: problem with a mail.app script
  • Next by Date: "do shell script" mail
  • Previous by thread: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
  • Next by thread: Re: (2 of 2) Application Scripting Question - Theoretical? (was Re: Technote 2106 is da Bomb)
  • Index(es):
    • Date
    • Thread