• 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: Code completion suggestion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code completion suggestion


  • Subject: Re: Code completion suggestion
  • From: has <email@hidden>
  • Date: Thu, 21 Oct 2004 17:57:01 +0100

steve harley wrote:

 > Code completion in Real basic is really good. If you type in an object
 > and add a period it comes up with all its elements and properties and
 > you can then start typing and it will narrow the list down.

the notation won't help.. AppleScript is weakly typed (a variable's
value may be an object of any class), so when you type "get c's ...",
Script Editor will have no way to know the class of c, and thus it
can't know what elements or properties c might have.. it sounds like
Real Basic is strongly typed (a variable's value can be of only one
class)

Yeah, intelligent auto-completion would be pretty tricky - it'd require too much information that's only available at runtime. A dumber auto-completion feature that simply matches against a list of all known words (i.e. language keywords, variable and handler names, osax commands and - within a 'tell application ...' block - application keywords) is an option for at least reducing the amount of typing you have have to do.


As far as the context-sensitive help aspect goes, there's probably not much could be done to help users find their way around their AppleScript code, but since most AppleScripts don't have a terribly complex structure this isn't such a big loss. The other thing users need is better tools to help them find your way around application object models - class browsers, inheritance tree viewers, etc. - and this is certainly an area with plenty room for development. While application dictionaries don't hold quite enough information to support such tools 100%, there's still enough to be fairly useful. So I think it's also possible to match - or even beat - RB for 'helpfulness' as well, as long as you're willing to take a different approach that plays to the particular strengths of your own language and tools. Some examples:

- You can use tools to view an application's inheritance tree and containment structure. Script Debugger has graphical versions of one or both (I can't remember), and I've written command line versions that produce diagrams like:

    -application
    -item
       |-track
       |   |-URL_track
       |   |-device_track
       |   |-etc...

- You could have a tool that allows you to construct [most] application references simply by pointing and clicking on property and element names in a tree-based browser. Mostly useful as a learning and exploration tool, though as a side-feature it could also generate the equivalent AppleScript source code and insert it into your script if you wanted. (I'd write this myself if it looked like there's some $$$ in it.)

- If you don't mind using another language, the next version of appscript (the application scripting package I'm developing for MacPython) is great for interactive exploration of running applications from the Python interpreter (I've been playing with this feature for several days and it's highly addictive:):

    [G4:~] has% /usr/local/bin/pythonw
    Python 2.3.3 (#2, Dec 23 2003, 22:56:29)
    >>> from appscript import *
    >>> i=app('itunes.app')
    >>> i.help()

--------------------------------------------------------------------------------
Appscript Help: iTunes.app
Reference: app(u'/Applications/iTunes.app')
Class: application -- The application program
Properties:
current_encoder : k.encoder (r/o) -- the currently selected encoder (MP3, AIFF, WAV, etc.)
current_EQ_preset : k.EQ_preset (r/o) -- the currently selected equalizer preset
...
Elements:
...
sources -- index | name | id
visuals -- index | name | id
windows -- index | name | id


--------------------------------------------------------------------------------
    app(u'/Applications/iTunes.app')
    >>> i.sources.help()

--------------------------------------------------------------------------------
Appscript Help: iTunes.app
Reference: app(u'/Applications/iTunes.app').sources
Element: sources -- index | name | id
Class: source -- a music source (music library, CD, device, etc.)
...


--------------------------------------------------------------------------------
app(u'/Applications/iTunes.app').sources
>>> _.get()
[app(u'/Applications/iTunes.app').sources.ID(31), app(u'/Applications/iTunes.app').sources.ID(190)]
>>> _[0].playlists.help()
etc...



HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Code completion suggestion
      • From: Bill Briggs <email@hidden>
  • Prev by Date: Re: file extension
  • Next by Date: Mount Volume with UAM?
  • Previous by thread: Re: Code completion suggestion
  • Next by thread: Re: Code completion suggestion
  • Index(es):
    • Date
    • Thread