Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: more than one script



Hi Wayne

1) How do you create two scripts in an ASS application? so that you could potentially point buttons to either of those scripts.. 
Just press command-N and select "AppleScript Text File" and name it - the path normally targets to the ASS project - and save it.
When you have done that the script will be visible in IB and you can link a button or whatever to that new script, but you can't connect an interface item to more than one script. But an interface object naturally can be controlled from more than one script.

2) How can you call on functions stored in the other script? 
You wil find an example within the ASS tutorials I think it's the Unit Converter.

You have to load the script into the other script like:
on findSmilePack()
set scriptPath to (scripts path of main bundle) & "/" & "createSmile" & ".scpt" as text
try
try
set packScript to load script POSIX file (scriptPath)
on error theError
log theError
end try
set smilePack to smilePack of packScript
set launchPackFound to true
on error theError
set launchPackFound to false
log {"packFound", scriptPath, theError}
end try
return launchPackFound
end findSmilePack

Or load it from another ASS application
on loadLibrarySTLScripts()
try
set scriptPath to missing value
set appPath to libraryPath & "sphericoSTLTools.app" as string -- libraryPath points to the folder of the application
set sphericoSTLToolsBundle to call method "bundleWithPath:" of class "NSBundle" with parameter appPath
-- Log what we got for the bundle.
log sphericoSTLToolsBundle


tell sphericoSTLToolsBundle
set scriptPath to path for script "sphericoSTLTools" extension "scpt"
end tell
-- scriptPath is slash-delimited; use POSIX file from the standard
--      scripting additions to convert it to a colon-delimited path,
--      which is expected by load script
set sphericoSTLToolsBundle to load script POSIX file (scriptPath)
set stltools to makeLibScript1() of sphericoSTLToolsBundle -- makeLibScript1() points to the script of the application
set stlToolsFound to true


on error theError
set stlToolsFound to false
log {"Problem getting library script.", theError}
end try
return stlToolsFound
end loadLibrarySTLScripts


Hope this helps

Andreas
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden

References: 
 >more than one script (From: Wayne Melrose <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.