• 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
Attempt of System Events to set variable renders it undefined
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Attempt of System Events to set variable renders it undefined


  • Subject: Attempt of System Events to set variable renders it undefined
  • From: Joseph Weaks <email@hidden>
  • Date: Sat, 20 Mar 2004 13:09:24 -0600

I want to check and see if any currently running app contains the user defined string.
Can someone explain why this script snippet is returning an error with an undefined variable, instead of leaving the variable alone?

set tempVar to "AppNotFound"
set inputSource to "someString"
tell application "Finder" to set tempVar to name of first process whose name contains inputSource
return tempVar

--When no app contains the string it returns error:
--"The variable tempVar is not defined."
--The return I was expecting is:
--"AppNotFound"


I thought that if no app was found, that it would leave the variable alone. My current workaround is

tell application "System Events" to set tempVar to name of first process whose name contains inputSource
try
tempVar
set contents of combo box "inputSource" of window "searchDialog" to inputSource
on error
set tempVar to "AppNotFound"
end try
return tempVar

Better method anyone?

thanks,
Joe Weaks
_______________________________________________
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.


References: 
 >Finally sat down and read 2106 (From: "John C. Welch" <email@hidden>)

  • Prev by Date: Re: Template for Debugging "on Open..." Handler
  • Next by Date: Search for the perfect ATID handler
  • Previous by thread: Finally sat down and read 2106
  • Next by thread: Search for the perfect ATID handler
  • Index(es):
    • Date
    • Thread