Re: facespan and reference usage/errors
Re: facespan and reference usage/errors
- Subject: Re: facespan and reference usage/errors
- From: Michael Miller <email@hidden>
- Date: Mon, 13 Aug 2001 23:09:07 -0500
At 9:25 PM -0700 8/11/01, Erik Norton wrote:
using OS 9.1 AS 1.6 FaceSpan 3.5.2 carbonLib 1.3.1
unable to create/manage a reference within a called
handler. i can do the following within the run handler
of a window or application script within FaceSpan ...
on run
set aLIST to {"a","b","c","d"}
set aREF to a ref to aLIST
set anITEM to aREF's item 1
activate
display dialog anITEM
end run
but if i set this within a called handler, it fails
(same script as a separate handler snipped)
obviously missing something. any ideas welcome.
First off, this has nothing to do with FaceSpan. The example given
also fails in the Script Editor.
If you declare your variable global (and fix the syntax problems)
then it works. Just add:
global aLIST
before the run handler in the second script. (I think this is why it
works the first time, if I remember the run handler variable scoping
rules.)
It also works if you make the reference outside the routine that uses it:
on run
aHANDLER()
end run
on aHANDLER()
set aLIST to {"a", "b", "c", "d"}
set aREF to a reference to aLIST
aHANDLER2(aLIST)
end aHANDLER
on aHANDLER2(someList)
set anITEM to item 1 of (contents of someList)
activate
display dialog anITEM
end aHANDLER2
I'm not sure why it messes up when you use the reference locally;
it's probably an AS bug. Of course, you shouldn't need to use the
reference locally, since you have the actual data right there.
::shrug::
Hope this helps,
Mike Miller
ESG Labs
http://www.esglabs.com/