Re: AsciiNumber & AsciiCharacter Handlers
Re: AsciiNumber & AsciiCharacter Handlers
- Subject: Re: AsciiNumber & AsciiCharacter Handlers
- From: Paul Skinner <email@hidden>
- Date: Tue, 7 May 2002 15:41:50 -0400
Thanks to Arthur and has for the feedback!
Arthur, I really liked the TIDs swapping tell block!
Here are versions that allow multiple character strings or lists of
single characters to be passed to asciiNumber and lists of numbers to be
passed to asciiCharacter.
asciiNumber("applescript rocks!")
-->{97, 112, 112, 108, 101, 115, 99, 114, 105, 112, 116, 32, 114, 111,
99, 107, 115, 33}
asciiCharacter({97, 112, 112, 108, 101, 115, 99, 114, 105, 112, 116, 32,
114, 111, 99, 107, 115, 33})
-->{"a", "p", "p", "l", "e", "s", "c", "r", "i", "p", "t", " ", "r",
"o", "c", "k", "s", "!"}
property asciiCharacterList : run script "
set a to {}
repeat with i from 0 to 255
set a's end to ascii character i
end
return a as string"
on asciiCharacter(parameters)
set output to {}
repeat with thisParameter in parameters as list
set the end of output to item (thisParameter + 1) of my
asciiCharacterList
end repeat
if length of output is 1 then return item 1 of output
return output
end asciiCharacter
on asciiNumber(parameters)
set output to {}
if class of parameters is string then set parameters to characters
of parameters
repeat with thisParameter in parameters as list
tell (a reference to text item delimiters)
set {previousTIDs, contents} to {contents, thisParameter}
set {ind, contents} to {my asciiCharacterList's text item
1's length, previousTIDs}
end tell
if ind > 255 then error "invalid input"
set the end of output to ind
end repeat
if length of output is 1 then return item 1 of output
return output
end asciiNumber
--
Paul Skinner
_______________________________________________
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.