Re: Perl-like modules in AppleScript?
Re: Perl-like modules in AppleScript?
- Subject: Re: Perl-like modules in AppleScript?
- From: John Kawakami <email@hidden>
- Date: Thu, 15 Mar 2001 17:22:12 -0800
Howdy all,
I used to be an avid applescripter and have still been doing doing some
things on the side but my recent job has landed me square in the middle of
the UNIX world and I have been mostly using Perl. While I still find
Applescript the easiest and equally as robust as Perl in most ways, I do
have one sort of functionality that I cannot seem to figure out how to
emulate or reproduce.
Is there some way to "modularize" functions in Applescript much like in
Perl. And to be clear, I am not referring to scripting additions (though
technically the equivalent are modules). For instance, there is a module
for Perl called HTML::Template that allows you to pass certain parameters to
be inserted in an HTML Template for return to a web visitor. It does the
job of reading in the file, finding the insertion points (based on module
specific tags in the template), and replacing the insertion tags with the
values of the variables you passed to it.
What would be the like functionality in Applescript?
I look forward to the discussion.
Greg Strange
Hi! I'm a perl head getting into AS (again) and what you want to do
isn't that hard. It's just not well documented, save a great
description in this AS column.
http://maccentral.macworld.com/columns/briggs.shtml
You use script objects, and it's the basis for AS's object oriented
style of scripting.
You load a script object like this:
set Thing to load script "path:to:script"
You make an object like this:
copy Thing to newObj
Well, actually, you can just use Thing itself, but if you need many
Things, you can just copy them.
And you use it like an object:
set aProperty of newObject to true
runAMethod(xx) of newObject
A script object is just a script. You can also define a script
object in your current script, like this:
script Thing
property aProperty : false
on runAMethod(yy)
--
end runAMethod
end script
I believe that you don't use the script...end script construction if
you're going to use "load script" on it. Maybe I'm wrong.
--
--------------------------------------
John Kawakami
email@hidden
Bush + Cocaine = Trouble.