Re: Scope of a property...
Re: Scope of a property...
- Subject: Re: Scope of a property...
- From: "Gary (Lists)" <email@hidden>
- Date: Sun, 28 Mar 2004 12:01:53 -0500
On Mar 27, 2004, at 9:37 PM, David Crowe wrote:
>
>>
>
>> I have a script with a handful of routines to manage a list that is
>
>> a property (e.g. add a string to the list, display the list, clear
>
>> the list).
>
>>
>
>> When I run a series of test function calls from within the script
>
>> it works perfectly.
I think your own message scope is a bit off too. It's not a very clear
question...or clarification. ;) I do think I get what you are trying to do,
however, so...
'Scope of a property' is not the issue. The issue is your use of AS inside
FileMaker, I think.
>
>> When I call the "add" function from another script (initiated from
>
>> FileMaker) and then run the print function of the list management
>
>> script file, the list appears to be empty.
More confusion. Now there are two scripts?
>
>> Do I have a different scope, and therefore a different value of the
>
>> property when I'm running the script from FileMaker and when I'm
>
>> running it standalone?
>
>>
>
>> Is this my problem, or is it something else perhaps?
>
>>
>
>> - David Crowe
At 12:27 AM -0500 3/28/04, Hanaan Rosenthal wrote:
>
>
>
> Hi David,
>
>
>
> Could you be a bit more specific?
>
> How exactly are you calling the script from FileMaker? Are you
>
> loading it or is it just using the 'perform AppleScript' script step
>
> in FM?
>
>
>
> Hanaan
David Crowe wrote [3/28/04 10:16 AM]:
>
Hanaan;
>
>
I do a "set field" and then execute the AppleScript from FileMaker
>
via a reference to that field. The contents of the field are just a
>
function call with the parameters filled in.
>
>
- David
From what I read, it sounds like you mean that you are storing the
AppleScript code in a field and then executing that code with the Perform
AppleScript script step, with the 'Perform field' option.
In any case where you use the Perform AppleScript script step, there are no
persistent properties, in AS parlance.
If you prefer (or need) to execute the script code from the contents of a
field, then the solution here is to store your "AS properties" in FM global
fields. [Keep in mind that global field contents are _not_ global per user
in a multi-user set-up...there is one global value per file.]
You can still use the AS keyword 'property', or you can use the (probably
more precise) 'global' variable declaration. The goal is to make the AS
value global in scope to the rest of your AS code, but using FM global
fields to keep values between script execution.
Also keep in mind that all the script code inside that field (or in any
Perform AppleScript script step) is being 'told' to FileMaker -- there is an
implicit 'tell' directing things to FM first in the terminology chain.
If you wish to have AS-level global persistent properties, then you can
always create the script as an application, then pass the FM-derived values
to the script using either a 'tell...run' or the Send Apple Event script
step.
You can _not_ have the following kind of calculation field in FM and hope to
have a persistent property in the AS usage of that word. (In my example,
the '|P' represents that paragraph marker from FM.)
field --> gMyScript [Calculation / Text Result]
"property myList : {}" & |P &
"set xItem to (cell """FM_Field_Value""" of current record) & |P &
"copy xItem to end of myList"
That kind of thing will _not_ work to store a persistent AS property value.
If you are constructing fields like this, and hope to run the script from
the field inside FM, then don't use 'property'. Just define a global
variable in AS, then repopulate the AS global from a FM global field each
time, storing the AS global value back in the FM global field at the end of
the usage, of course.
--
Gary
_______________________________________________
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.