0

Given two fields named Input and Output:

1.Typing Text or Morse Code into field Input should result in the the corresponding result in field Output.

So :
Text in field Input = Morse Code in field Output.
Morse Code in field Input = Text in field Output.

2.The conversion should take place as each letter or entity is typed into field Input.

3.Mixing Text and Morse Code in field Input is NOT permitted and your solution should allow input to field Input to be ignored if mixing is detected.

Special consideration needs to be given to periods (.), hyphens (-) and spaces ( ).

International Morse Code table below as reference.

Morse Code

I can’t write the solution in the bottom field. However the solution is : [code] on mouseUp put the text of field 1 into temp if matchChunk(temp,"[A-Za-z0-9]") then letterToMorse else morseToLetter end if end mouseUp on LetterToMorse put the text of field 1 into temp put empty into field 1 repeat for each char tC in temp put morse(tc) & space after field 1 end repeat end LetterToMorse function morse tC switch tc case space return " " #note that one space is added automatically case "a" return ".-" case "b" return "-..." case "c" return "-.-." case "d" return "-.." case "e" return "." case "f" return "..-." case "g" return "--." case "h" return "...." case "i" return ".." case "J" return ".---" case "k" return "-.-" case "L" return ".-.." case "m" return "--" case 1 return ".----" case 2 return "..---" case 3 return "...--" case 4 return "....-" case 5 return "....." case "N" return "-." case "O" return "---" case "P" return ".--." case "q" return "--.-" case "r" return ".-." case "s" return "..." case "t" return "-" case "u" return "..-" case "v" return "...-" case "w" return ".--" case "x" return "-..-" case "y" return "-.--" case "z" return "--.." case 6 return "-...." case 7 return "--..." case 8 return "---.." case 9 return "----." case 0 return "-----" end switch end morse on MorseToLetter #mange spaces replace " " with "§" in field 1 #we must start to longer sequences to shortest: replace ".----" with 1 in field 1 replace "..---" with 2 in field 1 replace "...--" with 3 in field 1 replace "....-" with 4 in field 1 replace "....." with 5 in field 1 replace "-...." with 6 in field 1 replace "--..." with 7 in field 1 replace "---.." with 8 in field 1 replace "----." with 9 in field 1 replace "-----" with 1 in field 1 replace "-..." with "B" in field 1 replace "-.-." with "C" in field 1 replace "..-." with "F" in field 1 replace "...." with "H" in field 1 replace ".---" with "J" in field 1 replace ".-.." with "L" in field 1 replace ".--." with "P" in field 1 replace "--.-" with "Q" in field 1 replace "...-" with "V" in field 1 replace "-..-" with "X" in field 1 replace "-.--" with "Y" in field 1 replace "--.." with "Z" in field 1 replace "-.." with "D" in field 1 replace "-.-" with "K" in field 1 replace "---" with "O" in field 1 replace ".-." with "R" in field 1 replace "..." with "S" in field 1 replace "..-" with "U" in field 1 replace ".--" with "W" in field 1 replace ".-" with "A" in field 1 replace ".." with "I" in field 1 replace "--" with "M" in field 1 replace "-." with "N" in field 1 replace "." with "E" in field 1 replace "-" with "T" in field 1 replace space with empty in field 1 REPLACE "§" with space in field 1 end MorseToLetter[/code]