# Is there a column-type to convert an array of A-Z to an array of 1-26 (position in the alphabet)?

**URL:** <https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425>\
**Category:** Ask for Help\
**Created:** [November 12, 2021, 6:37am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425 "2021-11-12T06:37:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 12, 2021, 6:37am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/1 "2021-11-12T06:37:45Z")

</div>

Hi!  
For an ice-breaker, I’d like each member to learn how to spell his/her name in International Aeronautical Code. You know “Alpha, Tango, Charlie”. So I can help him/her by displaying it. Or even Morse Code.  
Example for L-Y-M-E-I  
Lima-Yankee-Mike-Echo-India

J-E-F-F  
Juliet-Echo-FoxTrot-FoxTrot

funny, @Jeff_Hager: a typical US dance 🕺💃

D-A-R-R-E-N  
Delta-Alpha-Romeo-Romeo-Echo-November  
Don’t tell me your car happens to be an Alpha-Romeo. Or that you used to work for / fly on Delta Airlines

Is there a column-type/plugin to  
convert an array to another  
or  
convert each letter by its position in the alphabet (so an item from array 1 to another from array 2 same position)

or do I have to compute it myself?  
Thks 🌸

 ![CodeIntlSignauxMaritimesDrapeauxLegendes](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/3/d3bd1cd3b4852f513bca941e5c8850d93a21b544.png)  
 ![AlphabetChiffresEtMorseCompBeige](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/c/1c576b728860f1cc1b612000205edf2a0ff5c8b6.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [November 12, 2021, 7:00am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/2 "2021-11-12T07:00:10Z")

</div>

I don’t think any of the existing plugins will do it, but it wouldn’t be too difficult to write one.

I started having a play to see how far I could get without writing any code.

 ![Screen Shot 2021-11-12 at 2.57.04 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/5/e55de74f84eb031b8bbd537123c201647e40b499.png)

Not very 😂

I might come back to this later…

---

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 12, 2021, 7:09am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/3 "2021-11-12T07:09:09Z")

</div>

😄 Maybe there’s an existing code that we can just integrate like \</\> snippet to let even anonymous users play with?  
I know a “Shakespearien insult generator” or a “Tintin Captain Haddock (in French) insults generator”.  
Sometimes they can be integrated in the web site, don’t know if it’s allowed in Glide apps. The only pb can be the “raw design”.  
OK, have fun, Delta-Alpha-Romeo-Romeo-November 🧭  
BTW, my Name anagram could be EMILY  
I’d start by creating an array with the 26 letters to search in. And the 26 international codes.  
Then split the user name and go into each letter position in array 1 to retrieve the international match in array 2.  
If there’s a shortcut, or an existing plugin to insert in the app, anyone is welcome to say.

---

<div class="post-metadata">

**Author:** ![George-Glide](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george-glide/32/22384_2.png) [@George-Glide](https://community.glideapps.com/u/George-Glide)\
**Post date:** [November 12, 2021, 3:25pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/4 "2021-11-12T15:25:08Z")

</div>

This will work in a Javascript Code column. Just copy and paste into the code section.

Here is a copyable app that uses it [https://alpha-words.glideapp.io/](https://alpha-words.glideapp.io/)

Enjoy!

```auto
function alphaWord(text) {

  let alphaWord = ["Alpha", "Bravo", "Charlie", "Delta", "Echo",
  "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima",
  "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra",
  "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"]
  let result = '';
  text = text.toUpperCase();
  let unicodeNum;
  
  for (var i = 0; i < text.length; i++){
    unicodeNum = text.charCodeAt(i) - 65;
    if ((unicodeNum > -1) && (unicodeNum < 26)) {
      result += alphaWord[unicodeNum] + " ";
    } else {
      result += "- ";
    }
  }
  
  return result

}
return alphaWord(p1);

```

---

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 12, 2021, 6:03pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/5 "2021-11-12T18:03:45Z")

</div>

> [@George-Glide](#):
>
> [https://alpha-words.glideapp.io](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014)

Thks so much, George. I didn’t think JS was required for this. Good thing I ask first!  
I didn’t even plan to add this feature so quickly, but now I’ll have to😄, c’est malin !  
I just need to think of a nice way to maybe prompt for any other name than the current user’s, to let him/her play with and learn. Maybe just a text entry field and a button to trigger the conversion.  
EDIT: Just did it. Everything’s fine 🆗  
Very unexpectedly helpful. Hope you enjoyed it, George 🌸🥐🧸  
I mean Golf-Echo-Oscar-Romeo-Golf-Echo  
😊🧭🚢

---

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 12, 2021, 7:28pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/6 "2021-11-12T19:28:45Z")

</div>

Sorry if I reopen the topic for a little while, to adjust the code before checking again the Solution.  
1/remove the “-” for the last alpha code: it would be better to append a new item to the resulting table than to add a string to a resulting string. Getting a resulting table from the alpha table is more open to any management like separators.  
I should be able to replace this part of JS with an append in array. Though I’m not good at object languages like JS, but at “old school” Pascal & Basic.

2/a little issue with “long names” and Glide text fields (even the smallest or footnote)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/f/4fab13743b7cb648d94a92854248a3500716a63e.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/a/9a1e30b9e20a94614a55fbd08f74ceaf1d848737.png)  
I can save the two split and join column if the separator is directly inside the JS  
I chose “/” for composed first names  
Marie-Caroline is not very long, but it’s truncated in display.  
I added a new line to separate Marie and Caroline with result += ‘\n’;  
I also added a Remove Accents Column otherwise it’s not converted (and not sure how it works with other languages like Vietnamese names @ThinhDinh ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/a/6a5434a5466e9557f86880606aa70b36cae3b068.png)  
The Hint component cannot manage that with too big font size  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/5/45781c74cd6d54abd742215283700abc5bb7e190.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/5/a/5a6daf521bb26dcce4d96492e79727cb2794a370.png)

---

<div class="post-metadata">

**Author:** ![George-Glide](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george-glide/32/22384_2.png) [@George-Glide](https://community.glideapps.com/u/George-Glide)\
**Post date:** [November 13, 2021, 1:41pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/7 "2021-11-13T13:41:26Z")

</div>

Looks good. Hint, when posting code if you surround the text with three ticks (upper left next to the 1 on most keyboards). Use them like you would quotes but 3 ticks on each side. I usually put them on the preceeding line and the following line. Then you end up with copy and pastable code making it easier for others to use.

---

<div class="post-metadata">

**Author:** ![George-Glide](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/george-glide/32/22384_2.png) [@George-Glide](https://community.glideapps.com/u/George-Glide)\
**Post date:** [November 14, 2021, 2:39am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/8 "2021-11-14T02:39:45Z")

</div>

@L.M I made a small change to the code that handles those diacritics or accents inside the function so the extra column you added is not needed.

```auto
function alphaWord(text) {
  // set up the replacement array
  let alphaWord = ["Alpha", "Bravo", "Charlie", "Delta", "Echo",
  "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima",
  "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra",
  "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"]
  let result = '';
  
  // replace graphemes and diacritics. Credit to https://stackoverflow.com/a/37511463/1899661
  text = text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
  // convert to uppercase
  text = text.toUpperCase();
  let unicodeNum;
  
  for (var i = 0; i < text.length; i++){
    unicodeNum = text.charCodeAt(i) - 65;
    if ((unicodeNum > -1) && (unicodeNum < 26)) {
      result += alphaWord[unicodeNum] + " ";
    } else {
      result += "- ";
    }
  }
  
  return result

}

return alphaWord(p1)

```

---

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 14, 2021, 10:49am UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/9 "2021-11-14T10:49:40Z")

</div>

Thks, George 🙂  
BTW, I keep on getting this bug

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/b/cbadfb8f4bc3b18693440fa21e0018f89947191a.png)  
It doesn’t trouble the result, but, sth doesn’t agree with Glide

---

<div class="post-metadata">

**Author:** ![L.M](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/l.m/32/46371_2.png) [@L.M](https://community.glideapps.com/u/L.M)\
**Post date:** [November 19, 2021, 6:08pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/10 "2021-11-19T18:08:31Z")

</div>

Just changed the code to trim and replace spaces by point (for a more “code look”).  
The hyphen “-” is not necessary for the “code look”. I don’t think it is spelled on radio communications 😊  
I’ll just warn that the code cannot work with all special characters like Russian or some Vietnamese ones: it’s still supposed to be a code name, so.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/a/fab63d2368775c78984d96e93ca56b31b0690728.jpeg)

```auto
function alphaWord(text) {
  // set up the replacement array
  let alphaWord = ["Alpha", "Bravo", "Charlie", "Delta", "Echo",
  "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima",
  "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra",
  "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"]
  let result = '';
  
  // replace graphemes and diacritics. Credit to https://stackoverflow.com/a/37511463/1899661
  text = text.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
  // convert to uppercase
  text = text.toUpperCase();
  let unicodeNum;
  
  for (var i = 0; i < text.length; i++){
    unicodeNum = text.charCodeAt(i) - 65;
    if ((unicodeNum > -1) && (unicodeNum < 26)) {
      result += alphaWord[unicodeNum] + " ";
    } else {
      result += "";
    }
  }
  
  return result.trim().replace(/ /g, '·')

}

return alphaWord(p1)

```

I can close this topic. Thks so much, George.  
I’ll look at your other JS about Relative Time asap.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [November 20, 2021, 6:08pm UTC](https://community.glideapps.com/t/is-there-a-column-type-to-convert-an-array-of-a-z-to-an-array-of-1-26-position-in-the-alphabet/34425/11 "2021-11-20T18:08:57Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
