You are currently viewing the gmlscripts.pro static mirror. Forum access and script submissions are not available through this mirror.

Invert gmlscripts.pro

string_nato

Returns a given string as expressed by the NATO phonetic alphabet. Phonetic words will be separarted by spaces. Non-alphanumeric characters are removed.

text = "Testing: 1-2-3.";
nato = string_nato(text);

//  nato == "Tango Echo Sierra Tango India November Golf One Two Three"
string_nato(text)
Returns a given string as expressed by the NATO phonetic alphabet.
COPY/// string_nato(text)
//
//  Returns a given string as expressed by the NATO phonetic alphabet.
//  Phonetic words will be separarted by spaces. Non-alphanumeric 
//  characters are removed.
//
//      text        text to translate, string
//
/// gmlscripts.pro/license
{
    var in = string_upper(argument0);
    var len = string_length(in);
    var out = "";

    var nato = ds_map_create();
    nato[? "A"] = "Alfa";     nato[? "B"] = "Bravo";     nato[? "C"] = "Charlie";
    nato[? "D"] = "Delta";    nato[? "E"] = "Echo";      nato[? "F"] = "Foxtrot";
    nato[? "G"] = "Golf";     nato[? "H"] = "Hotel";     nato[? "I"] = "India";
    nato[? "J"] = "Juliett";  nato[? "K"] = "Kilo";      nato[? "L"] = "Lima";
    nato[? "M"] = "Mike";     nato[? "N"] = "November";  nato[? "O"] = "Oscar";
    nato[? "P"] = "Papa";     nato[? "Q"] = "Quebec";    nato[? "R"] = "Romeo";
    nato[? "S"] = "Sierra";   nato[? "T"] = "Tango";     nato[? "U"] = "Uniform";
    nato[? "V"] = "Victor";   nato[? "W"] = "Whiskey";   nato[? "X"] = "X-ray";
    nato[? "Y"] = "Yankee";   nato[? "Z"] = "Zulu";      nato[? "0"] = "Zero";
    nato[? "1"] = "One";      nato[? "2"] = "Two";       nato[? "3"] = "Three";
    nato[? "4"] = "Four";     nato[? "5"] = "Five";      nato[? "6"] = "Six";
    nato[? "7"] = "Seven";    nato[? "8"] = "Eight";     nato[? "9"] = "Niner";

    for (var i=1; i<len; i++) {
        var c = string_char_at(in ,i);
        if (!ds_map_exists(nato, c)) continue;
        if (i > 1) out += " ";
        out += nato[? c];
    }

    ds_map_destroy(nato);
    return out;
}

Contributors: xot

GitHub: View · Commits · Blame · Raw