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: Parent property by "path to", passing variables between script files



Hi Graham

Pleased to hear that you've solved your problem and simplified your scripts.

There's just one thing I have been wondering. Why do you need to keep track of which nibs are loaded? You wrote in an earlier email "globals that keep track of whether nibs are loaded, etc." Or, more to the point, why do you need to keep that information in global variables? As a rule I simply load all my nibs in the application's "on launched" handler. There's no great overhead and I know that from then on they are all loaded.

on launched theObject -- application launched
	load nib "abc"
	load nib "xyz"
	-- etc
end launched

I do want to control the showing or otherwise of windows, so I'll uncheck the "Visible at launch time" check box in Interface Builder for all my windows, and then use "show window ..." and "close window ..." as and when needed. You obviously have to load a nib containing a window before you try to "show" the window. If you load all your nibs right at the start when the application launches then you don't have to worry about that - everything's loaded. I can't, on the face of it, think of a reason for not loading the nibs up front. But if there is one, instead of keeping track of which at any particular time are loaded, how about simply trapping for it? Say you have a window in a nib and you want to be sure that the nib is loaded before you show the window, these lines would trap for it (in other words, the single line "if not ..." before the line "show window"):

	if not (exists window "nameOfWindow") then load nib "nameOfNib"
	show window "nameOfWindow"

Obviously I don't know your application, so there may well be a good reason why you need to keep track of the loaded nibs. And this is only a minor point. The major issue, that of simplifying your code, you have clearly solved. Your point about cutting dependency on global variables is a good one. I am sure that as a result you will find that your code is much easier to manage/update/build on etc.

Regards

Philip



On 24 Apr 2005, at 20:27, Graham Jones wrote:

Whoo hoo!

SOLVED!

Thanks to all, I'm back on track after three grueling weeks of confusion. I
moved all my "global to the application" variables back into the main
script, and am using that script as the sole controller, keeping track of
"nib loaded" booleans, etc, Then I pass whatever I need to pass to
subscripts via handler parameters, and use user defaults as often as I can.


The added bonus is that I have drastically cut my dependency on global
variables, and have been able to replace many globals and properties with
local variables, this freeing up memory and making my code simpler.


Thanks to Christopher Hickman, Jasper Van Proeyen, Philip Buckley, Matthew
Stuckwisch, Mark Butcher, and anyone else I'm forgetting... I'll put a
"special thanks" for you in the Read Me of my app!


Thanks again,
Graham Jones.

_______________________________________________
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


_______________________________________________ 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: 
 >Re: Parent property by "path to", passing variables between script files (From: Graham Jones <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.