This script returns the corresponding caracter to an ASCII number and viceversa. This was my first functional script, I now it’s very simple, but I liked this a lot since I begun.
OS version: OS X
set pregunta to "Choose entry form:"
set pedido1 to "Imput ASCII number: "
set pedido2 to "Imput Character: "
set aclaracion to "(If you writ more than one, only the first one will be consedered)"
set problema to "Not a valid value for this convertion."
repeat
display dialog pregunta buttons {"Quit", "ASCII", "Character"} default button 3
copy result as list to {respuesta}
try
if respuesta is "ASCII" then
display dialog pedido1 default answer "0 - 255" buttons {"OK"} default button 2
copy the result as list to {valor}
display dialog the "The number " & valor & " represents: " & (ASCII character valor) buttons {"OK"} default button 1
else if respuesta is "Character" then
display dialog pedido2 & return & aclaracion default answer "A" buttons {"OK"} default button 2
copy the result as list to {valor}
display dialog the "The Character " & valor & " is represented by: " & (ASCII number valor) buttons {"OK"} default button 1
else if respuesta is "Quit" then
exit repeat
end if
on error
display dialog problema buttons {"OK"} default button 1
end try
end repeat