Re: undefined variable
Re: undefined variable
- Subject: Re: undefined variable
- From: Matthew Smith <email@hidden>
- Date: Tue, 31 Jul 2001 08:37:34 +1000
Hmmm, I can see a few problems.
>
if "app" is active then # THIS IS WHERE I GET THE ERROR#
What this line says is if the text string "app" equals the variable active.
Yo have not define the variable active before. You are wanting to see if the
application is running. You need to do something like:
>
tell application "Finder"
>
repeat with i from 1 to (the number of application processes)
>
if (the creator type of application process i) is "POrg" then
>
tell application "Palm Desktop" to quit
>
end if
>
end repeat
Someone may suggest something better but what you have to do is find the
active process for the application from the Finder and then tell it to quit.
I have used the creator code in my example as it gets around any renaming of
the application file, which is possible.
I couldn't work out what you were doing here:
>
if "app" is active then # THIS IS WHERE I GET THE ERROR#
>
tell application "Finder"
>
activate
>
end tell
>
quit application "app"
>
else
>
tell application "app"
>
activate
>
quit application "app"
>
end tell
>
end if
If your if condition worked then when the condition was true you would make
the Finder the front application and the quit your application. If it was
false you would make your application the front application and then quit
it. You don't need to make anything the front application, especially not to
when you are then going to quit it, unless you expect some dialog box to
appear. Even so, the results would be slightly different if your
applications was frontmost or not.
>
tell application "Finder"
>
activate
>
if exists folder "appfolder" of startup disk then
>
select folder "appfolder" of startup disk
>
delete selection
>
empty trash
>
else
>
quit application "Script Editor"
>
end if
>
end tell
You have wrapped this part in a tell application "Finder", but it is already
in one. It could be rewritten as:
>
if exists folder "appfolder" of startup disk then
>
delete folder "appfolder" of startup disk
>
empty trash
>
end if
You don't need to make something the selection in order to work with it in
the Finder. You can reference it directly.
I could work out what you would want to quit the Script Editor if you
weren't deleting the application's folder. If you save the script as an
applet then the Script Editor wouldn't be running.
--
Matthew Smith