Global variables
Global variables
- Subject: Global variables
- From: Larry the O <email@hidden>
- Date: Thu, 8 Mar 2007 08:02:20 -0800
OK, I must be misunderstanding something really basic here.
All I'm trying to do is create a droplet that starts out by declaring
and initializing a bunch of global variables, then runs a series of
subroutine calls to do the work. The idea of using the global
variables is so that the subroutines can read and write the global
variables without them having to be explicitly passed in the
subroutine call, right?
Not working. It worked when I was writing the code and running it
directly from the script window, but once I added the droplet front
end (which was independently tested and seems to work fine), the
global variables are no longer working.
The actual code is kind of messy right now, so, for the moment,
makePretend code:
on open
global littleMess
global bigMess
global ohMiGod
set littleMess to {}
set bigMess to ""
set ohMiGod to "toilet paper"
bumpAndGrind()
twistAndShout()
shakeAndBake()
end open
--
on bumpAndGrind()
set littleMess to {"incontinent dog", "naughty cat"}
display dialog "Pivot and spin"
end bumpAndGrind
--
on twistAndShout()
if bigMess is "" then
set bigMess to "Uncle Ben's Rice"
end if
end twistAndShout
--
on shakeAndBake()
if ohMiGod is "toilet paper" then
set bigMess to "You don't want to know."
else
set littleMess to {"cleanup effort", "disaster recovery"}
end shakeAndBake
----------------------
Now, shouldn't that work, that is, shouldn't the subroutines be able
to read and write the global variables? But it's not. Instead, I'm
having to pass each global variable in the call and explicitly return
the changed variable at the end of the routine.
Is the problem that the subroutines should all be inside the open
statement?
Thanks!
larry the o
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden