on mouseUp
-- First, get rid of anything that's in the
-- "results" field
put empty into card field "results"
-- Now go through each word of the "input" field
repeat with i = 1 to number of words of card field "input"
-- translate the ith word of the "input" field
put word i of card field "input" into wordToTranslate
translateWord wordToTranslate
-- add an extra space to separate the words
put " " after card field "results"
end repeat
end mouseUp
-- This is a message handler which translates into Morse
-- Code the word specified by whichWord. It displays
-- the translated word after whatever is in card field
-- "results"
on translateWord whichWord
-- Go through each character of the word to be translated
repeat with j = 1 to number of chars of whichWord
put char j of whichWord into charToTranslate
-- to translate the character, go through each line of the
-- codes field
repeat with i = 1 to number of words of card field "codes"
-- if character 1 of the current line of the codes field
-- matches the character to translate, then the morse code
-- corresponding to the character to translate is the second
-- word of the current line of the codes field
if word 1 of line i of card field "codes" = charToTranslate then
put word 2 of line i of card field "codes" after card field "results"
end if
end repeat
end repeat
end translateWord