Applescript Limits

I made a script that tests the length limits of “string”, “Unicode text” and «class utf8»:

If you choose “string” it returnes a maximum of: 16.270.000 characters
If you choose “Unicode Text” it returnes a maximum of: 8.000.000 characters
If you choose “«class utf8»” it returnes a maximum of: 8.000.000 characters

I couldn’t find any source with official limits in Applescript.

Are there any other known limits?

Limits for: “integer”, “number”, “real”, “list”, “record”?

(Limits refer to System 10.4.2)


set a to ".-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-"
set b to "" as string --or Unicode Text or «class utf8»
repeat 100 times
	try
		set b to b & a
	on error
		exit repeat
	end try
end repeat
count b
-- b = ten thousand
set c to ""
repeat 100 times
	try
		set c to c & b
	on error
		exit repeat
	end try
end repeat
count c
-- c = million
set d to ""
repeat 100 times
	try
		set d to d & c
	on error
		exit repeat
	end try
end repeat
count d
repeat
	try
		set d to d & b
	on error
		exit repeat
	end try
end repeat
count d
repeat
	try
		set d to d & a
	on error
		exit repeat
	end try
end repeat
count d
repeat
	try
		set d to d & ".-.-.-.-.-"
	on error
		exit repeat
	end try
end repeat
count d
set runs to 1
repeat 10 times
	try
		if (runs mod 2) = 0 then
			set d to d & "-"
		else
			set d to d & "."
		end if
		set runs to runs + 1
	on error
		exit repeat
	end try
end repeat
count d

The AppleScript documentation does discuss the limits, for example the page for ‘real’ numbers ( http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.31.html ) states:

The largest value that can be evaluated (positive or negative) is 1.797693e+308.

whereas the page for Integers ( http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangGuide/AppleScript.2e.html ) states:

The largest value that can be expressed as an integer in AppleScript is 536870909, which is equal to (2 29 - 3)

I don’t believe there’s any specific limit on records or lists, other than available memory.

Nice, thanx!

I made a script that should make an (in)finite list containing uncountable copies of “” ( {“”,“”,“”,“”,.} ).
It adds 10000 items at a time. I let it run over the night - It was still running when I woke up - no error - still adding items!
Seems you are right with lists’ limits. :smiley:

But why these strange limits?
What is so special with 1.797693e+308 or 536870909 ?