• 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: Creating a script from another script in AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a script from another script in AS


  • Subject: Re: Creating a script from another script in AS
  • From: Andrew Oliver <email@hidden>
  • Date: Wed, 18 May 2005 11:25:49 -0700

On 5/17/05 12:24 PM, "Francois Houle" <email@hidden> wrote:

> However, you could elaborate more on your last sentense:
>
> "Have you considered doing this without using the Script Editor?
> 'osacompile can create a script app from the command line/shell."
> I'm still relatively new to this so what you are talking about is still
> quite obscure ! :)

Sure.

There are easier ways of saving a standalone script other than launching
script editor and driving it.

The first is the built-in 'store script' command which will compile and save
a script. The second is to use the shell command 'osacompile' which will
take a text file, compile it and spit out an executable version.

In the first case, using 'store script':

--- BEGIN SCRIPT ---
script myScript
    property user_info : ""

    tell application "Finder"

        try

            mount volume "afp://" & user_info

        on error

            display dialog "There was an error mounting the shared drive."
buttons {"Cancel"} default button 1

        end try

    end tell
end script
set scripts_folder to (path to desktop folder from user domain) as text
set file_name to "Testfile.app"

set myScript's user_info to "user:pass@1.1.1.1/HardDrive"

store script myScript in (scripts_folder & file_name)

--- END SCRIPT ---

Here you see how to embed one script object within another, using 'store
script' to separate them out at runtime. You also get the advantage of being
able to see the script syntax highlighting. As long as you use a .app
filename you get a double-clickable executable, however, there's no option
for the 'run only' feature. To get that you need osacompile.

In this case I'd use the exact same script above, but don't 'store script'
as a .app file, just create a .scpt file:

 set file_name to "Testfile.scpt" -- note the different filename
 store script myScript in (scripts_folder & file_name)

Then pass that file to osacompile using the -x switch to make it run-only:

 do shell script "osacompile -o /path/to/testfile.app -x
~/Desktop/testfile.scpt"

This will create a run-only executable application at /path/to/testfile.app
based on the script code in ~/Desktop/testfile.scpt

Hope that helps.

Andrew
:)

 _______________________________________________
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

References: 
 >RE: Creating a script from another script in AS (From: "Francois Houle" <email@hidden>)

  • Prev by Date: Re: Image Capture Scripting dictionary is missing in Tiger
  • Next by Date: How to Reference a Chart in an AppleWorks Spreadsheet
  • Previous by thread: RE: Creating a script from another script in AS
  • Next by thread: PDF button in Print dialog in Tiger and UI element
  • Index(es):
    • Date
    • Thread