Re: can I do this better?
Re: can I do this better?
- Subject: Re: can I do this better?
- From: has <email@hidden>
- Date: Sun, 16 Jun 2002 13:48:49 +0100
Geoff Canyon wrote:
>
>I wrote this little routine to trim off any trailing or beginning spaces or
>
>returns. would any of u pros do it differently or better? if so, how and
>
>why?
>
>
Apologies for the slightly off-topic post, but this is such an excellent
>
example for the use of chunk expressions I couldn't resist. Chunks are
>
available in HyperCard, SuperCard, and Revolution, all of which support
>
AppleScript execution as well (in different ways).
>
>
In chunks, the above could be accomplished with:
>
>
put word 1 to -1 of tString into tString
In AS, it would be:
set tString to text (word 1) thru (word -1) of tString
Not appropriate here as punctuation will be omitted from beginning and end
of string, not just whitespace. Definitely has its uses, however. [1]
And:
>
Assuming that you're responding to my post, I wasn't talking about using
>
AppleScript, but Revolution (or SuperCard or HyperCard). They have a very
>
similar syntax to AppleScript, and built-in syntax for dealing with words,
>
as opposed to having to set delimiters in AppleScript. The result is, as
>
far as the original poster described, exactly what was asked for, in a
>
single line of code:
>
>
put word 1 to -1 of tString into tString
Does this statement include leading/trailing punctuation? AS is quite
precise about what constitutes a "word" so it doesn't, but Transcript may
take a different approach.
has
[1] Though it breaks down, unfortunately, when you try to use more complex
references:
text (word 2 of paragraph 2) thru (word 2 of paragraph 3) of theString
This compiles, but behaves incorrectly when you run it, so I'm guessing
there's a bug somewhere. Anyone know?
--
http://www.barple.connectfree.co.uk/ -- The Little Page of Beta AppleScripts
_______________________________________________
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.