;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfStrToMorse (strString) ; Version 1. If strString == "" Then Return "" strString = StrUpper (strString) strMorse = "" intLen = StrLen (strString) For intI = 1 To intLen Switch Char2Num (StrSub (strString, intI, 1)) Case 065 ; "A" strMorse = strMorse : ".-" Break Case 066 ; "B" strMorse = strMorse : "-..." Break Case 067 ; "C" strMorse = strMorse : "-.-." Break Case 068 ; "D" strMorse = strMorse : "-.." Break Case 069 ; "E" strMorse = strMorse : "." Break Case 070 ; "F" strMorse = strMorse : "..-." Break Case 071 ; "G" strMorse = strMorse : "--." Break Case 072 ; "H" strMorse = strMorse : "...." Break Case 073 ; "I" strMorse = strMorse : ".." Break Case 074 ; "J" strMorse = strMorse : ".---" Break Case 075 ; "K" strMorse = strMorse : "-.-" Break Case 076 ; "L" strMorse = strMorse : ".-.." Break Case 077 ; "M" strMorse = strMorse : "--" Break Case 078 ; "N" strMorse = strMorse : "-." Break Case 079 ; "O" strMorse = strMorse : "---" Break Case 080 ; "P" strMorse = strMorse : ".--." Break Case 081 ; "Q" strMorse = strMorse : "--.-" Break Case 082 ; "R" strMorse = strMorse : ".-." Break Case 083 ; "S" strMorse = strMorse : "..." Break Case 084 ; "T" strMorse = strMorse : "-" Break Case 085 ; "U" strMorse = strMorse : "..-" Break Case 086 ; "V" strMorse = strMorse : "...-" Break Case 087 ; "W" strMorse = strMorse : ".--" Break Case 088 ; "X" strMorse = strMorse : "-..-" Break Case 089 ; "Y" strMorse = strMorse : "-.--" Break Case 090 ; "Z" strMorse = strMorse : "--.." Break Case 048 ; "0" strMorse = strMorse : "-----" Break Case 049 ; "1" strMorse = strMorse : ".----" Break Case 050 ; "2" strMorse = strMorse : "..---" Break Case 051 ; "3" strMorse = strMorse : "...--" Break Case 052 ; "4" strMorse = strMorse : "....-" Break Case 053 ; "5" strMorse = strMorse : "....." Break Case 054 ; "6" strMorse = strMorse : "-...." Break Case 055 ; "7" strMorse = strMorse : "--..." Break Case 056 ; "8" strMorse = strMorse : "---.." Break Case 057 ; "9" strMorse = strMorse : "----." Break Case 192 ; "À" strMorse = strMorse : ".--.-" Break Case 197 ; "Å" strMorse = strMorse : ".--.-" Break Case 196 ; "Ä" strMorse = strMorse : ".-.-" Break Case 200 ; "È" strMorse = strMorse : ".-..-" Break Case 201 ; "É" strMorse = strMorse : "..-.." Break Case 214 ; "Ö" strMorse = strMorse : "---." Break Case 220 ; "Ü" strMorse = strMorse : "..--" Break Case 223 ; "ß" strMorse = strMorse : "...--.." Break Case 209 ; "Ñ" strMorse = strMorse : "--.--" Break Case 046 ; "." strMorse = strMorse : ".-.-.-" Break Case 044 ; "," strMorse = strMorse : "--..--" Break Case 058 ; ":" strMorse = strMorse : "---..." Break Case 059 ; ";" strMorse = strMorse : "-.-.-." Break Case 063 ; "?" strMorse = strMorse : "..--.." Break Case 045 ; "-" strMorse = strMorse : "-....-" Break Case 095 ; "_" strMorse = strMorse : "..--.-" Break Case 040 ; "(" strMorse = strMorse : "-.--." Break Case 041 ; ")" strMorse = strMorse : "-.--.-" Break Case 039 ; "'" strMorse = strMorse : ".----." Break Case 061 ; "=" strMorse = strMorse : "-...-" Break Case 043 ; "+" strMorse = strMorse : ".-.-." Break Case 047 ; "/" strMorse = strMorse : "-..-." Break Case 064 ; "@" strMorse = strMorse : ".--.-." Break Case 032 ; " " strMorse = strMorse : " " Break EndSwitch Next Return strMorse ;.......................................................................................................................................... ; This UDF "udfStrToMorse" converts a given string into it's equivalent Morse code. ; ; strCharsLatin = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ; 26 upper alpha chars. ; strCharsNum = "0123456789" ; 10 numerical chars. ; strCharsSpecial = "ÀÅÄÈÉÖÜßÑ.,:;?-_()'=+/@" ; 23 special chars. ; Note: CH = "----" ; not handled by this code. ; ; Detlev Dalitz.20090703.20101223. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ ; Test. strString = "SOS" strMorse = udfStrToMorse (strString) ; strMorse = "...---..." strMsgTitle = strString strMsgText = strMorse Message (strMsgTitle, strMsgText) strString = "- ( [<{Hello}>] World! ) ? ." strMorse = udfStrToMorse (strString) ; strMorse = "-....- -.--. ......-...-..--- .-----.-..-..-.. -.--.- ..--.. .-.-.-" strMsgTitle = strString strMsgText = strMorse Message (strMsgTitle, strMsgText) Exit