• 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: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)


  • Subject: Re: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 23 Feb 2003 09:33:51 -0800

On 2/23/03 8:35 AM, "Paul Skinner" <email@hidden> wrote:

> It means that I can pass a string of length 5000 characters, and I
> won't have a problem addressing every character despite the 4069+/-
> item limit on text to list conversion. Nice!

Just to let you know it's not 4069. It's a variable limit; I have no idea
what the parameters might be for what the limit is in specific
circumstances. I always used 4000 as a cut-off point, thinking it was more
than generous (although I had already seen a couple of problems with lists
of c. 4030 items.) Then one day I had it fail on a list of 3992 text items:
3991 was OK, 3992 not OK. So now I use 3900 as my cut-off point.


> Why hasn't this been clearly stated? It seems to be an excelent
> optimization technique.

Individual characters are a very special case. 99% of the time the text
items I'm creating with text item delimiters, or paragraphs, are not
individual characters. I'll have very little use for this, but it's very
useful to know.

A related technique, demonstrated previously by has and others, makes use of
the same huge speed improvements of strings over lists. Instead of

if someList contains {someString} ...

do something like this (using tids you know to be safe):

set AppleScript's text item delimiters to {";;;"}
set longString to ";;;" & someList as string & ";;;"
set AppleScript's text item delimiters to {""}
if longString contains (";;;" & someString & ";;;") then ...


This is also much faster, sometimes 100% faster. It's a great technique. It
works as well for Unicode text, which is particularly useful when setting a
list 'as Unicode text' if you choose your tids so you can extract a list
again at the end if need be.

--
Paul Berkowitz
_______________________________________________
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: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
      • From: Paul Berkowitz <email@hidden>
References: 
 >repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters) (From: Paul Skinner <email@hidden>)

  • Prev by Date: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
  • Next by Date: Re: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
  • Previous by thread: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
  • Next by thread: Re: repeat with i in string optimization was Re: Understanding a repeat loop (strings/characters)
  • Index(es):
    • Date
    • Thread