Global Variables through multiple subroutines
Global Variables through multiple subroutines
- Subject: Global Variables through multiple subroutines
- From: Ketan Majmudar - Spirit Quest <email@hidden>
- Date: Thu, 31 Jul 2003 11:52:54 +0100
Hi,
I've tried searching through the archives and am inundated a little.
I'm trying to understand the best ways of minimizing unecessary processing and time factors.
A script I'm writing checks the dock items through System Events and then the processes running
through System Events.
The two are cross referenced to get all User Applications running whether hidden or not.
see an example below:
property controlList : {"Mouse Control", "Refresh List", "_______________"}
on showAppList()
try
set appCheck to ""
set appList to {}
tell application "System Events"
set DockList to name of UI element of application process "Dock"
set processList to title of every process
repeat with appCheck in DockList
if processList contains appCheck then
if appList does not contain appCheck then
set appList to appList & appCheck as list
end if
end if
end repeat
set myList to myList & controlList
set myList to myList & appList
end tell
on error
beep
end try
end showAppList
on switchApp()
try
tell application "System Events"
if index is greater than (length of controlList) then
set myApp to item (action) of myList
set frontmost of process myApp to true
end if
end tell
on error
beep
end try
end switchApp
my showAppList()
the list myList now contains a list with all running user processes, even if hidden.
But I want the user to be able to choose an item and have the list available in the subroutine
switchApp() and more likely others as the full script is much longer.
Unless there is an easier way to return Only the User Processes via applescript.
I've tried lots of options of global vars but I can't seem to get my head round it. I don't want to
run showAppList() again as the time it takes to process is way too long for the user.
Its not really possible to use libraries or external code as I am writing this for an application
that triggers predefined scripts from an external device. So it needs to be self contained.
Thanks.
Ket
Any ideas would be appreciated.
--
Ketan K Majmudar
Spirit Quest
w::
http://www.spiritquest.co.uk
e:: email@hidden
t:: +44(0)20 8346 7553
----------------------------
Holistic - Ethical - Local - Global Solutions
_______________________________________________
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.