• 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: 'include' statement in applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'include' statement in applescript


  • Subject: Re: 'include' statement in applescript
  • From: "Marc K. Myers" <email@hidden>
  • Date: Wed, 26 Jan 2005 12:10:28 -0500

If I understand what you mean by an "include" statement, this is how I implement it:

1.Store all your include modules in a library
2.At the top of your script make a "property" statement that contains the path to your module library as text.
3.Have a property statement for each of your include modules, using the path from #2.
4.Call methods from the include modules using the names of the properties from #3.


For example:

Save this as a compiled script named "wiggleScript":

	on wiggle()
		display dialog "Hello, World!"
	end wiggle

This is your calling script:

	property myLib : (path to desktop) as text
	property myWiggle : load script alias (myLib & "wiggleScript.scpt")

	wiggle() of myWiggle

Set up this way, the include modules will load at compile time only. If you change your include modules all you need to do is recompile the scripts that use them. If you want the include module loaded "live" every time you run the calling script you put the "load script" in your mainline code.

on Tue, 25 Jan 2005 15:43:40 -0800, Graham Anderson stated:
still it would be nice to have a real 'include' statement without
loading/compiling scripts
I'll check out the 'load script' command

g
On Jan 25, 2005, at 2:49 PM, Brian Johnson wrote:


On Tue, 25 Jan 2005, Graham Anderson wrote:

I was doing that before..but if you've got a fairly long script...it
makes it a bit harder to deal with

so, does applescript have some kind of include capability ?

if not, I'll go back to calling handlers within handlers :(

Here's a suggestion that might help. If you're using Script Editor on an OS-X box, go to the file menu, pick "Open Dictionary". Scroll through the list to "standard additions" and pick it. What you'll see is a list of the commands that come built in to AS. Expand "Scripting Commands" to find "load script". It does what you want to do.

Alternative, write hander1 as

  on handler1(whatever)

    .. lots of AS stuff ..

    return "handler1 done at "&(current date) as text

  end handler1

and save it as a stay-open application named "handler1". Repeat with
handlers 2 and 3. Now, write the main application:

  set football to tell application "handler1" to handler1( params )
  set baton to tell application "handler2" to handler2( football )
  set buck to tell application "handler3" to handler3( baton )

  display dialog "Handoffs:" & buck

So, it's easy to do even large projects in AS, as long as you work in
a modularized way. Good luck.

_______________________________________________ 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
  • Prev by Date: Re: iWork Pages
  • Next by Date: Re: reference by location in iTunes
  • Previous by thread: Re: 'include' statement in applescript
  • Next by thread: RE: launch remote script on OS9 machine from OSX machine
  • Index(es):
    • Date
    • Thread