Re: variables vrs properties
Re: variables vrs properties
- Subject: Re: variables vrs properties
- From: Robert Poland <email@hidden>
- Date: Wed, 5 Jan 2011 08:59:37 -0700
Luther,
If I remember right with Snow Leopard, saving as an application creates an application bundle.
My question; Would an application typically execute faster that a script?
On Jan 5, 2011, at 8:32 AM, Luther Fuller wrote:
On Jan 5, 2011, at 9:10 AM, Jim Brandt wrote:
> What exactly are the advantages/disadvantages to using properties over variables?
>
> Property • global within scope
> • retains value until script is recompiled
>
> Variable • global within scope only if declared global
> • doesn't retain value between executions
I always compile my scripts as application bundles, so these remarks may not apply if you don't.
You can change the value of a property in an AppleScripted application, but probably shouldn't because that makes your application file self-modifying. This is not compatible with codesigning (which I don't yet use).
Global variables are a bad thing for the same reason. Global variables ARE persistent ... they DO retain their value between executions. For this reason, I never use globals.
> Other than these two distinctions, is there any reason to use a property over a variable?
>
> Along these same lines, some here have suggested I use a .plist file to set certain predefined values (I was asking specifically about a default file location for source and library files).
>
> Why would a .plist file be advantageous over just a plain text file? Either way, if have to run code to set a variable and thus can't use properties built on that variable, which is the original intent.
> I have read Luther's Property List tutorial. While it describes some of how to read and write all or part of a .plist file from Applescript, it still doesn't answer --why-- I would want to do this?
.plist files are easier to read/write than text files.
> While I am an old school programmer (Fortran, Cobol and some PHP), and have a fair understanding of programming methods, I have never used Xcode or any other tools Apple provides to program my Mac other than AS and a very little Unix cmd line stuff.
>
> I'm using 10.4.11 on a PowerPC as my main platform and thus only have Xcode 2. Luther's tutorial addresses features in the Property List Editor that showed up in Xcode 3, which requires an Intel processor. Thus I question why I need to go through the process of learning a whole new technology to create and use one file for the specific purpose of pointing scripts to a source location.
>
> While the learning of new technology can be a good thing, it seems like a little overkill here.
>
> Am I missing something?
I haven't (yet) used Xcode with AppleScript. My plist tutorial should apply to any Mac OS X version and both PPC and Intel. Once you see how to use .plist preference files it's easy and isn't overkill at all.
Robert Poland - Fort Collins, CO
_______________________________________________
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