Jump to content

NATO Phonetic Converter


NerdFencer
 Share

Recommended Posts

Here is a quick script that I wrote to convert text into NATO phonetic (Alfa, Bravo, Charlie, Delta, Echo Foxtrot, Etc...)

Its not big (wow, a whole 39 lines!) but it gets the job done.

It was written to save me a bit of time, but a friend found it amusing, so I figured I'd post it...

#NoTrayIcon
GUICreate("Whiskey Tango Foxtrot",350,150)
GUICtrlCreateLabel("Enter your text in the top box, then click "&Chr(34)&"Convert"&Chr(34)&" to convert it into NATO Phonetic (which will appear in the bottom box)",10,10,330,30)
Global $input = GUICtrlCreateInput("Enter Text Here",10,50,330,23)
Global $output = GUICtrlCreateInput("Conversion will be here",10,80,330,23)
Global $convert = GUICtrlCreateButton("Convert",10,110,100,-1,1)
Global $Copy = GUICtrlCreateButton("Copy",240,110,100)
Global $TTS = GUICtrlCreateButton("Say",125,110,100)
Global $NATO = StringSplit("Alfa |Bravo |Charlie |Delta |Echo |Foxtrot |Golf |Hotel |India |Juliet |Kilo |Lima |Mike |November |Oscar |Papa |Quebec |Romeo |Sierra |Tango |Uniform |Victor |Whiskey |Xray |Yankee |Zulu ","|")
Global $objVoice = False, $temp

GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $Copy
            ClipPut(GUICtrlRead($output))
        Case $TTS
            If IsBool($objVoice) Then
                $objVoice = ObjCreate("SAPI.SpVoice")
                $objVoice.Volume = 90
                $objVoice.Rate = 1
            EndIf
            $objVoice.Speak(GUICtrlRead($output), 1)
        Case $convert
            $split = StringSplit(GUICtrlRead($input),"")
            $combined = ""
            For $i=1 To $split[0]
                For $j=1 To $NATO[0]
                    $temp = Asc(StringUpper($split[$i]))-Asc("A")+1
                    If $temp < UBound($NATO) And $temp>0 Then $split[$i] = $NATO[$temp]
                Next
                $combined = $combined & $split[$i]
            Next
            GUICtrlSetData($output,$combined)
    EndSwitch
WEnd

*Edit - Changed window title to "Whiskey Tango Foxtrot" :D

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Link to comment
Share on other sites

I was thinking about doing something like this the other day but decided not to. So I used yours to make it. I didn't make it so the speak works, I could use system beep, but ehhhh don't feel like it :D

Morse Code

#NoTrayIcon
GUICreate("Whiskey Tango Foxtrot",350,150)
GUICtrlCreateLabel('Enter your text in the top box, then click "Convert" to convert it into Morse Code (which will appear in the bottom box)',10,10,330,30)
Global $input = GUICtrlCreateInput("Enter Text Here",10,50,330,23)
Global $output = GUICtrlCreateInput("Conversion will be here",10,80,330,23)
Global $convert = GUICtrlCreateButton("Convert",10,110,100,-1,1)
Global $Copy = GUICtrlCreateButton("Copy",240,110,100)
Global $TTS = GUICtrlCreateButton("Say",125,110,100)
Global $NATO = StringSplit(".-   |-...   |-.-.   |-..   |.   |..-.   |--.   |....   |..   |.---   |-.-   |.-..   |--   |-.   |---   |.--.   |--.-   |.-.   |...   |-   |..-   |...-   |.--   |-..-   |-.--   |--.. ","|")
Global $objVoice = False, $temp

GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $Copy
            ClipPut(GUICtrlRead($output))
        Case $TTS
            If IsBool($objVoice) Then
                $objVoice = ObjCreate("SAPI.SpVoice")
                $objVoice.Volume = 90
                $objVoice.Rate = 1
            EndIf
            $objVoice.Speak(GUICtrlRead($output), 1)
        Case $convert
            $split = StringSplit(GUICtrlRead($input),"")
            $combined = ""
            For $i=1 To $split[0]
                For $j=1 To $NATO[0]
                    $temp = Asc(StringUpper($split[$i]))-Asc("A")+1
                    If $temp < UBound($NATO) And $temp>0 Then $split[$i] = $NATO[$temp]
                Next
                $combined = $combined & $split[$i]
            Next
            GUICtrlSetData($output,$combined)
    EndSwitch
WEnd

Giggity

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...