;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfStrToMorse (strString) ; Version 4. If strString == "" Then Return "" ; Chars = 26 upper alpha chars + 10 numerical chars + 23 upper special chars + one space char. Note: "CH" = "----" ; Not handled by this code. strChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" : "0123456789" : "ÀÅÄÈÉÖÜßÑ.,:;?-_()'=+/@" : " " strString = StrUpper (StrClean (strString, strChars, "", @FALSE, 2)) ; Remove all other unknown chars. arrChars = ArrayFromStr (strChars) strMorseLatin = ".-|-...|-.-.|-..|.|..-.|--.|....|..|.---|-.-|.-..|--|-.|---|.--.|--.-|.-.|...|-|..-|...-|.--|-..-|-.--|--.." ; 26 codes. strMorseNum = "-----|.----|..---|...--|....-|.....|-....|--...|---..|----." ; 10 codes. strMorseSpecial = ".--.-|.--.-|.-.-|.-..-|..-..|---.|..--|...--..|--.--|.-.-.-|--..--|---...|-.-.-.|..--..|-....-|..--.-|-.--.|-.--.-|.----.|-...-|.-.-.|-..-.|.--.-." ; 23 codes. arrMorse = Arrayize (strMorseLatin : "|" : strMorseNum : "|" : strMorseSpecial : "|" : " ", "|") ; 60 codes (59 codes plus one space). objDict = CreateObject ("Scripting.Dictionary") objDict.CompareMode = 0 ; BinaryCompare, i. e. "That" != "that" intLast = ArrInfo (arrChars, 1) - 1 For intI = 0 To intLast objDict.Add(arrChars [intI], arrMorse[intI]) Next strMorse = "" intLast = StrLen (strString) For intI = 1 To intLast strMorse = strMorse : objDict.Item(StrSub(strString, intI, 1)) Next objDict.RemoveAll Drop (objDict) 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 = "ÀÅÄÈÉÖÜßÑ.,:;?-()'=+/@" ; 22 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