Re: Settings backup script
Re: Settings backup script
- Subject: Re: Settings backup script
- From: Arthur J Knapp <email@hidden>
- Date: Fri, 03 Aug 2001 12:01:22 -0400
>
Date: Fri, 03 Aug 2001 13:52:41 +1000
>
Subject: Re: Settings backup script
>
From: Shane Stanley <email@hidden>
>
On 3/8/01 12:05 PM +1000, Nigel Garvey, email@hidden,
>
> It's the characters of a string that are counted by default, so 'number of
>
> MyComments', or 'length of MyComments', or 'count MyComments' will tell you
>
> how many characters there are in the string. The expression 'number of
>
> characters of MyComments' is the same as 'number of (characters of
>
> MyComments)'. It first makes a list of the individual characters - eg. {"H",
>
> "e", "l", "l", "o"} - and then counts the items in the list. The answer's
>
> exactly the same, but it uses more memory and takes a little longer.
This is exactly how I would interpret what happens when you do:
count of characters of x
But Shane may have proved this wrong:
>
I'm not entirely convinced of this, although I'm open to persuasion. But if
>
I run the following script:
>
set time1 to the ticks
>
repeat 10000 times
>
set a to characters of x
>
set a to count of characters of x
>
set a to length of x
>
set a to count of x
>
{time2 - time1, time3 - time2, time4 - time3, time5 - time4}
>
>
I typically get something like {117, 13, 12, 10}. This suggests to me that:
>
(a) "count of characters of" doesn't actually build a list, given how long
>
just building a list takes;
I would have to assume that this is because "characters" is being treated
as a parameter to the "count" command, rather than as a reference form of
the string, ie:
(count of characters of x) is same as (count x each character)
rather than:
count (characters of x)
>
(b) getting "length of" is not appreciably faster than "count of characters
>
of"; and
Typically, I prefer "length of" simply because it "feels" more efficent
to use something AppleScript calls a property rather than a command, (this
is NOT to say that it actually is more efficent, as we can't know what's
going on behind the scenes).
Of course, it's always a little dangerous to make assumtions about
these things. For instance, it's entirely possible that:
set a to count of characters of x
IS building the list, but that it operates faster than:
set a to characters of x
because of some aspect of bring a list into a variable, rather than simply
creating an intermedite list that gets sent to the count command.
There is certianly a speed difference between:
characters of someString
and:
set aVariable to characters of someString
as has been shown in the past.
Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden
Hey, check out:
http://home.earthlink.net/~eagrant/