char code of

need
char code of " " → 32
char code of any char ->…

This does it

return ASCII number of "a"
--returns 97

Tiger or earlier:


set x to "a"
ASCII number x --> 97

Leopard:


set x to "a"
id of x --> 97

thanx :smiley:

If you are using it in multi-version software:

on ord(char)
	if (system version of (system info)) < "10.5" then
		return ASCII number char
	else
		return id of char
	end if
end ord

ord("a") --> 97, no matter what version you're running.

This should work for all versions.

Hi Sean,

there is actually non need for a distinction.
In a pure Leopard environment id is preferable, but for compatibility ASCII number also works