• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: undefined variable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined variable


  • Subject: Re: undefined variable
  • From: Steven Angier <email@hidden>
  • Date: Tue, 31 Jul 2001 08:52:31 +1000
  • Organization: Macscript.com

> i am trying to write an apple script to check to see if a certain program
> is running. if it is running, then the script quits the apllication and
> deletes it. if the application is on the hard drive and isn't running. it
> deletes it. and, if the program isn't on the hard drive, or running, then
> it just quits. i have everything working, but trying to get applescript
> to check to see if the application is active or running. i run into an
> undefined variable.

Our Macscript.com Library has functions that can help you do this:

There is a function called GetAppRecord() which you feed the creator type of
the application you are looking for and it returns a record of information
about the app. For example:

GetAppRecord("ToyS") --the creator type of the Script Editor

Returns a record:

{
appExists : true,
name : "Script Editor",
file : "Macintosh HD:Apple Extras:AppleScript:Script Editor",
alreadyRunning : false
}


You could then write something like:

--first, get the application record
set theAppRecord to GetAppRecord("ToyS")

--return if the app doesn't exist
if not (appExists of theAppRecord) then return

--otherwise, quit the app if it is running
if (alreadyRunning of theAppRecord) then quit application (name of
theAppRecord)

--you can then delete the application file itself (I use Jon's Commands
here)...
deleteFile (file of theAppRecord)

--or delete its parent folder using another library function,
GetParentFolder()
deleteFile GetParentFolder(file of theAppRecord)


A sample of the library is available on our website.

Hope this helps.

Steven Angier
Macscript.com


References: 
 >undefined variable (From: <email@hidden>)

  • Prev by Date: Size restriction on a variable?
  • Next by Date: Can't seem to script printing PostScript file
  • Previous by thread: Re: undefined variable
  • Next by thread: Re: undefined variable
  • Index(es):
    • Date
    • Thread