Mailing Lists: Apple Mailing Lists

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

Unable to access a library from individual scripts, after loading it at the application level



All,

The example contains 4 nibs (2 windows, and 2 panels). Each nib has its own script, and I would like to load a library once, at the application level, which is why I am loading it using the "on launched theObject" handler of MainWindow.applescript.
What I did was select the "File's Owner" for "MainWindow.nib" and enabled the "launched" attribute in the "File Owner's Inspector" window, which would make one think that, that is the "application level", thus should be accessible by other objects within the application (script).


( 1 ) I would like to access the library's vars and handlers from each of the scripts attached to the different nibs, without reloading the library individually for each nib.

( 2 ) Also I have not been successful in calling handlers from the Project_Lib.scpt that access handlers contained within the individual scripts. i.e. Need a tell statement within Project_Lib.scpt that calls a handler in MessageWindow.applescript

MainWindow.nib
MainWindow.applescript

MessageWindow.nib
MessageWindow.applescript

AlertPanel.nib
AlertPanel.applescript

SettingsPanel.nib
SettingsPanel.applescript

Project_Lib.scpt  -- common library used by all four nib scripts



MainWindow.applescript contains an "on launched theObject" handler that loads a common library

-- +---------+---------+---------+---------+---------+--------- +---------+---------+
-- MainWindow.applescript
-- +---------+---------+---------+---------+---------+--------- +---------+---------+
property use_custom_messages : true
property show_event_debug : true
-- +---------+---------+---------+---------+
on launched theObject
set AS_Studio_project_lib_filepath to (AS_Studio_GetPath2Dir ("scripts", "text") & "project_lib.scpt")
set proj_lib to (load script file AS_Studio_project_lib_filepath)

try
set (proj_lib)'s use_custom_messages to my use_custom_messages
set (proj_lib)'s show_event_debug to my show_event_debug
(proj_lib)'s AS_Studio_ShowMessage("Starting Up Alert Panel..." & return & AS_Studio_project_lib_filepath & return)
on error
AS_Studio_ShowMessage("Starting Up Alert Panel..." & return & AS_Studio_project_lib_filepath & return)
end try
end launched
-- +---------+---------+---------+---------+


BOTH of the scripts below generate an error that the "variable proj_lib is undefined". For some reason I cannot access the library loaded at the application level from any of the other nib scripts

-- +---------+---------+---------+---------+
-- AlertPanel.applescript
-- +---------+---------+---------+---------+
on opened theObject
	tell application of theObject
		set myStr to "LOADING AlertPanel.applescript."
		(proj_lib)'s dialog_ShowNow(myStr) -- generates error
	end tell
end opened
-- +---------+---------+---------+---------+
-- SettingsPanel.applescript
-- +---------+---------+---------+---------+
on opened theObject
	tell application of theObject
		set myStr to "LOADING SettingsPanel.applescript."
		(proj_lib)'s dialog_ShowNow(myStr) -- generates error
	end tell
end opened
-- +---------+---------+---------+---------+

Grateful for any insights...

Bill Hernandez
Plano, Texas

_______________________________________________
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


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.