Re: AppleScript seems to be Unique...
Re: AppleScript seems to be Unique...
- Subject: Re: AppleScript seems to be Unique...
- From: email@hidden
- Date: Wed, 1 Aug 2001 11:41:30 -0400
Wed, 1 Aug 2001 12:26:56 +0200, Alexander Schrieken <email@hidden> asked,
To: email@hidden
>
A couple of days ago I asked the list how unique
>
AppleScript was, and if Windows-users e.g. have
>
access to a similar utility.
>
>
The number of reactions to that question was
>
absolutely minimal (two). This could be
>
>
(A)
>
because there is no way Windows-users can do the
>
same things AppleScript let's Mac-users do, or
>
>
(B)
>
because the subscribers to this list are simply
>
unaware of the features that Windows offers in
>
this respect.
Its more complicated than that. Windows has a number of evolving things ("COM"
and "DCOM" and "OLE" and "DDE" ) that do inter-application communication. They
have something (Visual Basic) that is sort of like AppleScript, but it doesn't
come stock with the operating system, and its more like a programming language
and less like a scripting language. Its based more on little software pieces
(ActiveX objects, which are like scripting additions) than AppleScript is. As
the user you have to do more work to use these, though: you have to set each one
up before using it. Here's a code snippet from the O'Reilly "VB & VBA In a
Nutshell" book, by Paul Lomax
Dim ofsFileSys As New FileSystemObject
Dim ofsFiles As Files
Dim ofsFile as File
Set ofsFiles = ofsFileSys.Drives("C").RootFolder.Files
Set ofsFile = ofsFiles.Item("autoexec.bat")
MsgBox ofsFile.DateCreated & vbCrLf & _
ofsFile.DateLastModified & vbCrLf & _
ofsFileDateLastAccessed
Set ofsFile = Nothing
Set ofsFiles = Nothing
Set ofsFileSys = Nothing
The equivalent AppleScript would be like this
tell application Finder
set ofsFileInfo to info for file "Startup Script" of startup items folder
end tell
display dialog "" & creation date of ofsFileInfo & return & ,
modification date of ofsFileInfo
If you are manipulating an application, you do things like this:
Dim objDoc as Document
Set objDoc = Word.Application.ActiveDocument
objDoc.whatever()
Which would be the equivalent of an AppleScript like this:
tell document 1 of application "Microsoft Word" to whatever()
Do these example capture all the fundamental differences between Apple's Open
Scripting Architecture, AppleEvents, and AppleScript, and Microsoft's Common
Object Model, ActiveX, and Visual Basic? Of course not. But perhaps its a
start.
But I'll reiterate one important difference: AppleScript comes on every Mac,
and everyone can use it. Only developers can use Visual Basic in Windows. You
need to either have Visual Studio or a Microsoft application like Access that
uses Visual Basic for Applications. (Or you can write Visual Basic Script
applications in with a text editor and get them to download into a browser, but
then you have no access to the "dictionary" of the ActiveX controls, and need
written documentation of the names and methods.) The average use can use Visual
Basic for Applications to automate a specific app, like making macros in Word,
but you need better tools if you want to use Visual Basic to integrate
applications into a workflow. Integrating applications is something that
AppleScript does very well.
--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden