re: Strange problem with text item delimiters
re: Strange problem with text item delimiters
- Subject: re: Strange problem with text item delimiters
- From: Kai <email@hidden>
- Date: Wed, 02 Jul 2003 09:49:51 +0100
on Mon, 30 Jun 2003 16:36:35 -0400, David Crowe wrote:
>
I'm not sure about your analysis of the problem.
I could have expressed it better, David. :-)
>
I'm trying to get the text items of the "name of aFile", which is not
>
the same as "aFile as string" (this gives the entire path name,
>
rather than just the name within its folder). So, I was not trying to
>
go directly from an alias.
Quite so - and I'm sorry if that's the impression I gave. What I meant was
simply that 'text items' needs to act on *text* (which 'name' would normally
return - in one form or another).
Since, on the system I was using, your syntax resulted in an error <Can't
get every text item of name of alias "XYZ">, the object being considered
(name of alias "XYZ") had clearly not been evaluated as text before the
attempt to extract its text items.
So in spite of the parentheses intended to dictate the sequence of
evaluation, the partial result was a reference to <name of alias "XYZ">
rather than a text value. Marc put it better, and his explicit use of the
'get' command demonstrated an effective method (especially in a single line)
of evaluating the reference to the application object first - before the
AppleScript expression <text items of [text value]> was considered.
(This perhaps highlights another point mentioned - that, where possible,
it's safer to avoid mixing the evaluation of application objects and
AppleScript expressions.)
The error generated OMM was number -1728 (errAENoSuchObject - which
indicates a run-time resolution error). This is usually caused by specifying
an object that doesn9t exist. For example:
----------------
first item of {}
--> error: Can't get item 1 of {}. (error number: -1728)
text 1 thru 4 of "foo"
--> error: Can't get text 1 thru 4 of "foo". (error number: -1728)
items of string
--> error: Can't get every item of string. (error number: -1728)
numbers of 123
--> error: Can't get every number of 123. (error number: -1728)
----------------
However, as I understand it, your code OYM seems to be producing results
more consistent with these examples:
----------------
items of {foo:"foo", bar:"bar"}
--> {}
words of {"foo", "bar"}
--> {}
text items of ""
--> {}
----------------
What *should* happen with your original code is perhaps debatable, but I
still feel that the inconsistent behaviour between the 2 systems indicates a
bug in one of them.
>
I did try the following script:
>
>
tell application "Finder"
>
set aRandomFile to first file of startup disk
>
set FileName to (name of aRandomFile)
>
class of (FileName)
>
end tell
>
>
This gives "Unicode text" for the class (of the name of an alias),
>
which verifies Emmanual's point.
Right. I believe that item properties returned by the Finder as Unicode text
now include: 'name', 'displayed name', 'name extension', 'kind',
'description', 'comment', 'URL', 'owner' and 'group'. (Formerly, most of
these were returned as international text.)
However, in spite of the odd glitch with Unicode text (one of which I
demonstrated in my previous message), I'm still not convinced that it's the
culprit here - unless this snippet also causes a problem for you:
--============================================
set aFile to "afilename.doc" as Unicode text
set text item delimiters to "."
set ParsedFilename to aFile's text items
set text item delimiters to {""}
ParsedFilename
--> {"afilename", "doc"}
--============================================
>
Given that this problem just started happening, I wonder if a recent
>
upgrade to AppleScript perhaps changes this, because I don't know how
>
the script previously worked (which it did).
I never doubted it for a moment. ;-)
--
Kai
_______________________________________________
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.