• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: can I do this better?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: can I do this better?
      • From: Geoff Canyon <email@hidden>
  • Prev by Date: Re: AppleScript CGI and Mac OS X?
  • Next by Date: Re: inculding and reading from files
  • Previous by thread: Re: can I do this better?
  • Next by thread: Re: can I do this better?
  • Index(es):
    • Date
    • Thread