• 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: text to list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text to list


  • Subject: Re: text to list
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 01 Dec 2002 10:29:50 -0800

On 12/1/02 6:52 AM, "Timothy Bates" <email@hidden> wrote:

>> From: John Clark <email@hidden>
>> Is there anyway I can convert text to a list.
>>
>> "102030405060708090" to {"1", "2", "3", etc}
>>
>> I've tried text delimiters but they won't allow me to use the " delimiter
>
> set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text
> item delimiters, {"0"}}
> set a to text items of "102030405060708090"
> set AppleScript's text item delimiters to oldTIDs
> return a
> --> {"1", "2", "3", "4", "5", "6", "7", "8", "9", ""}

If you have more than about 4060 digits not counting all the zeroes, you
will get "stack overflow" error (or "Out of Memory" maybe, in AS 1.9.) Use
this subroutine, with "0" as tid, in conjunction with Tim's script.

set theText to "102030405060708090" -- or long text
set {oldTIDs, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {"0"}} -- one line
try
set a to text items of theText
on error
set a to my LargeTids(theText, "0")
end try
set AppleScript's text item delimiters to oldTIDs
return a



on LargeTidsList(theText, tid)

local newList, a, z, done

set AppleScript's text item delimiters to {tid}
set {a, z} to {1, 4000}
set newList to {}
set done to false
repeat until done
try
set newList to newList & text items a thru z of theText
set {a, z} to {a + 4000, z + 4000}
on error -- last segment, fewer thn 4000
set newList to newList & text items a thru -1 of theText
set done to true
end try
end repeat
set AppleScript's text item delimiters to {""}

return newList
end LargeTidsList





--
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.

References: 
 >Re: text to list (From: Timothy Bates <email@hidden>)

  • Prev by Date: Re: text to list
  • Next by Date: Re: text to list
  • Previous by thread: Re: text to list
  • Next by thread: Re: text to list
  • Index(es):
    • Date
    • Thread