Re: Property immutability
Re: Property immutability
- Subject: Re: Property immutability
- From: julifos <email@hidden>
- Date: Fri, 28 Feb 2003 12:43:16 +0100
>
property lastSaverlaunched : missing value --pid of last Saver launched.
>
set activeSavers to getRunningSavers()
>
if activeSavers is {} then set lastSaverlaunched to missing value
>
>
if lastSaverlaunched is missing value then
>
if activeSavers is {} then
>
set lastSaverlaunched to runSaver(chooseSaver())
>
else
>
display dialog "You are already running a screensaver. Please quit it
>
before launching this application"
>
end if
>
else --script has previously launched a saver.
>
set action to button returned of (display dialog "What would you like
>
to do?" buttons {"Cancel", "Change Saver", "Quit Saver"} default button
>
"Cancel")
>
if action is "Quit Saver" then quitSaver(lastSaverlaunched)
>
if action is "Change Saver" then
>
set previousSaverPID to lastSaverlaunched
>
set lastSaverlaunched to runSaver(chooseSaver())
>
delay 1 --allow the new saver to launch before removing the old one.
>
quitSaver(previousSaverPID)
>
end if
>
end if
>
>
>
Ok, I run this repeatedly in the editor and all is fine. I run it as
>
an application and the property lastSaverlaunched never gets modified
>
when the action is "Change Saver". The saver is changed, but the
>
property doesn't change, so the previous server isn't killed. Why?
Hmmm... Not pretty sure, but seems that lastSaverlaunched is good.
If you append these lines to the end of your code:
try
display dialog (lastSaverlaunched as text)
end try
try
display dialog (previousSaverPID as text)
end try
You'll see that lastSaverlaunched is correctly updated. Your problems is
previousSaverPID. These are my results after running it several times:
lastSaverlaunched previousSaverPID
1175 nope
1194 1175 --> ok, was lastsaverlaunched
1217 1175 --> BAD!
1239 1217 --> ok
1262 1217 --> BAD!
This serie is allways {initialize, good, bad, good, bad, good, bad...}
Very interesting! ;-) Not funny, but so interesting...
JJ
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.