Re: Extracting from text [Lecture]
Re: Extracting from text [Lecture]
- Subject: Re: Extracting from text [Lecture]
- From: Nigel Garvey <email@hidden>
- Date: Fri, 1 Mar 2002 11:16:46 +0000
"Marc K. Myers" wrote on Thu, 28 Feb 2002 18:40:18 -0700:
>
> Subject: Extracting from text [Lecture]
>
> Date: Thu, 28 Feb 2002 18:29:02 +0000
>
> From: Nigel Garvey <email@hidden>
>
> set AppleScript's text item delimiters to {":"}
>
> set parentPath to (text items 1 thru -3 of folderPath) as string
>
>
>
> This isn't perhaps as potentially calamitous as listing and then coercing
>
> the individual characters of a large text, but its use does seem to
>
> suggest that the authors don't know about the equivalent 'text'
>
> construction, which is (in its simplest form):
>
>
>
> text 1 thru text item -3 of folderPath
>
>
If you use "text item -3" the script would have to create a list of the
>
text items in order to identify text item -3, right?
I don't see why it should. There may be some under-the-bonnet pointer
shuffling, but there's no need actually to create a list physically. I
doubt that a list's created when you use 'character -3' instead. That
would be ridiculous.
>
That's a much
>
different situation than extracting a substring from a string using the
>
"text" command.
Normally, 'text item -3' itself returns a substring. In the context of
the 'text' command, it's a boundary parameter that indicates a *location*
in the original string. It only works that way with the 'text' command
(or one of the others of which I wrote).
>
Does it really save anything in that case?
About a third of the execution time, on one of my machines.
>
It seems
>
that it would be more complicated, internally, to mix "text" and "item"
>
terminology.
Only the compiler has to worry about this. If it comes across the phrase
"text item -3" at a point where it's expecting a boundary parameter for a
text command, it can simply compile the code appropriate to the situation.
NG
_______________________________________________
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.