Re: global variables
Re: global variables
- Subject: Re: global variables
- From: Deivy Petrescu <email@hidden>
- Date: Wed, 17 Jul 2013 19:44:17 -0400
On Jul 17, 2013, at 18:23 , Luther Fuller <email@hidden> wrote:
> On Jul 17, 2013, at 4:57 PM, Kaydell Leavitt wrote:
>
>> On Jul 17, 2013, at 2:13 PM, Luther Fuller <email@hidden> wrote:
>>
>>> This means that the application (bundle) is self modifying.
>>>
>>> Which, in turn, means that use of global variables will interfere with, for example, codesigning and perhaps other security measures used in Lion or Mt Lion.
>>
>> I see.
>>
>> These self-modifying apps that Apple's AppleScript Editor makes, isn't Apple breaking its own rules?
>
> I think this is a case of Apple not thinking thru the consequences of making globals persistent.
> It isn't necessary, but it has been so since the beginning of AppleScript and we are stuck with it.
>
>> I would think that apps shouldn't modify themselves, and that they shouldn't even create files in the same directory as they are running in, that apps should save their state in the following location:
>>
>> ~/Library/Saved Application State/<bundle ID>.savedState
>
> I just checked this and found that only one of my applications has a folder within ~/Library/Saved Application State/, but it is empty. I don't know how it got there. What do I need to do in code to put something there? Is there a reference document on this?
>
> When my applications need to save data, I use a preference (.pist) file in the preferences folder.
>
Every top level variable is persistent in AS.
All of them.
One does not need to declare it global to make it persistent.
One of the differences between globals and properties is that properties does not need to be set to anything ***after*** declaration whereas global does need to be set.
Now to see persistency check this script and run it more than once:
try
set x to x + 1
on error
set x to 1
end try
display dialog x
Deivy Petrescu
email@hidden
_______________________________________________
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