I have tried to use a construct like this, but AppleScript barks when for instance I pass a text with 20.000 characters, do anyone know where the limit goes?
to streamer by aText
script o
property l : characters of aText
end script
end streamer
My very old memory (which is odd from time to time) say that the length of a single text variable is restricted to 2^14 (two bytes).
My memory was wrong as demonstrated with :
property liste : {}
set beg to "0123456789abcdef"
set liste to {}
repeat 1024 times
set end of liste to beg
end repeat
set texte to liste as text
set liste to {}
set texte to texte & texte
count of texte
Yvan KOENIG (VALLAURIS, France) mercredi 26 septembre 2012 17:47:21
Before Tiger, there used to be a limit of around 4,000 on the number of elements (characters, words, paragraphs, or text items) which could be extracted from text in one go. I don’t know what the limit is now (I didn’t think there was one), but the old workaround still works and is quite fast:
to streamer by aText
script o
property l : missing value
end script
set lst to {}
set len to (count aText)
repeat with i from 1 to len by 3900
set j to i + 3899
if (j > len) then set j to len
set lst to lst & characters i thru j of aText
end repeat
set o's l to lst
end streamer
Yes it is there, and I’m sitting (not on!) but with a machine in front of me, with 8GB of Ram, and I am limitied to passing 16384 items at a time!
You know, Applescript becomes more and more suitable as a serious language, for each new generation of machines, but those limits, I think they should be dealt with! (10^6 or 10^9 seeming more reasonable.
Executing the pagesize utility shows that a memory page is under that limit anyway, The limit is actually four pages (pages beeing 4096 bytes on my system anyway), so AS have to deal with several memorpages as it is. It uses maybe 8 byte per address, if each element is to be adressed individually (64-bit addressing), then it will use 131072 bytes, to address said 16384 elements, but I am actually having 8GB of memory, and I would gladly fork some it to AppleScript, instead of having to consider ridiculous constraints by todays standards.
Thanks for the code! It is snagged, and will probably be used in one form or other!