Attempt of System Events to set variable renders it undefined
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.