Re: Deleting last item of a List
Re: Deleting last item of a List
- Subject: Re: Deleting last item of a List
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 20 Nov 2004 16:55:10 -0800
On 11/20/04 4:10 PM, "Nigel Garvey" <email@hidden>
wrote:
> kai wrote on Sat, 20 Nov 2004 15:45:45 +0000:
>
>> On Sat, 20 Nov 2004 13:47:21 +0000, Nigel Garvey wrote:
>>
>>> I had a look in the AppleScript Language Guide this morning. It says:
>>>
>>> [quote]
>>> beginning | front
>>> end | back
>>>
>>> The beginning and front forms are equivalent and refer to the first
>>> insertion point of the container (insertion point 1). The end and back
>>> forms are equivalent and refer to the last insertion point of the
>>> container (insertion point -1).
>
>>> [/quote]
>>>
>>> The assertions of equivalence are wrong - at least, with regard to
>>> AppleScript Language lists. "Front" and "back" can only be used
>>> adjectivally and are equivalent to "first" and "last" respectively.
>
>> Interesting. There seems to be a contextual thing going on here in
>> terms of equivalence:
>>
>> set l to {"a", "b", "c"}
>
>> l's back
>> --> "c"
>
> Even more interesting! I said above that "front" and "back" were *not*
> equivalent to "beginning" and "end" because I kept getting errors when
> trying to use them in that context. With both AS 1.3.7 (current when ASLG
> was written) and AS 1.9.1 (in Jaguar):
>
> back of l
> --> Error: Can't get after {"a", "b", "c"}
>
> But, on both systems, using Kai's Germanic genitive:
>
> l's back
> --> "c"
>
> An equivalence failure of a different kind. :-)
>
> Trying a bit harder, I find that this also works on both systems:
>
> (back) of l
Same here in AS 1.9.2. That looks as if 'back of' is compiling as a
different AppleEvent from '(back) of'. It doesn't appear to be a scripting
addition since both words compile as AppleScript language keywords according
to the formatting. Nevertheless it looks like 'back of' might be a
parameter to or property of some AppleScript class that's taking precedence
and imposing its raw code.
In Smile, using "Property & class to raw code", (back) of l' turns into
«class l»
(that's a lower-case L) with 2 squares for non-printing characters showing,
one each on either side of the l (they don't paste into Entourage here
except as blank spaces) The formatting is what I'd expect for a keyword or
constant (blue, not bold).
Trying it after compiling 'back of l' (and its error) gets
«class 9»
again with the two squares. 9? The formatting is as for AppleScript language
keyword this time - blue and bold.
When I copy and paste each non-printing character and get ASCII number,
they're all different Using the cursor and right arrow it's also clear that
there's an invisible character (ASCII 0) in each class name, so there really
are 4 characters, as there should be, for each.
Pasting the whole "l" from within «class l» - i.e. (back) of l - and
running:
set ls to {}
repeat with i from 1 to 4
set char to character i of "l" -- includes squares
set end of ls to (ASCII number char)
end repeat
ls
--> {2, 108, 0, 5}
(ASCII 108 is the l.)
Pasting "9" from within «class 9» - i.e. back of l -- with squares
results in
ls
--> {1, 57, 1, 0}
(ASCII 57 is the 9).
so they're clearly different commands. 'back of' without parentheses is
xoming up with something unexpected.
Just to be more confusing,
end of l
get the raw code
«class ;» -- no squares!
Running that in the script above gets
ls
--> {0, 59, 0, 0}
(Yup, there are 4 characters there, although it looks like just one. Moving
the right arrow through it confirms this.)
The blank and invisible characters may not survive the journey to an from
the list server, especially using plain text (and it may even muddle the
visible characters). You can replicate in Smile.
Script menu-->More menu bar-->More scripting-->Property & class to raw code
(in Smile 2.5.9).
>
> So I withdraw my earlier statement. 'Front' and 'back' *are* equivalent
> to 'beginning' and 'end' - or can be - so long as you remember to
> compensate for the compiler.
>
I wonder what it's up to here...
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden