Wednesday, September 12, 2007

Morse code in @Formula language and as a function in Sametime Bot

Here comes another post about using Lotus Notes' @Formula programming language for accomplishing different tasks. This time I'll show how to convert text to Morse code. Morse code is a method for transmitting telegraphic information, using standardized sequences of short and long elements to represent the letters, numerals, punctuation and special characters of a message.

The @Formula code is rather short. First we by specify 2 arrays: one with letters and another with corresponding morse code. Then we simply use @ReplaceSubstring function to replace the letters in the input text to corresponding elements in the morse array. As the number of elements in the 2 arrays are the same, @ReplaceSubstring function applies 1-to-1 element replacement.

letters:=" ":"A":"B":"C":"D":"E":"F":"G":"H":"I":"J":"K":"L":"M":"N":"O":"P":"Q":"R":"S":"T":"U":"V":"W":"X":"Y":"Z":"1":"2":"3":"4":"5":"6":"7":"8":"9":"0";
morse:=" ":".-":"-...":"-.-.":"-..":".":"..-.":"--.":"....":"..":".---":"-.-":".-..":"--":"-.":"---":".--.":"--.-":".-.":"...":"-":"..-":"...-":".--":"-..-":"-.--":"--..":".----":"..---":"...--":"....-":".....":"-....":"--...":"---..":"----.":"-----";
plaintext:="Morse code";
encoded:=@ReplaceSubstring(@UpperCase(plaintext);letters;morse+" ");

To reverse the process and convert from morse code to plain text following code can be used:

encoded:="-- --- .-. ... . -.-. --- -.. . ";
plain:=@ReplaceSubstring(@Implode(@Replace(@Explode(@ReplaceSubstring(encoded;" ";" _ ");" ");morse;letters);"");"_";" ");

I also implemented same morse formula as a function in Botstation Bot Framework, where user passes a text string to Sametime bot and receives the morse code as output. Here is a picture and a live example.
Bot command syntax:
demorse .. .-.. --- ...- . ... .- -- . - .. -- .

Morse Bot online example:



Anonymous said...

By the way, I recommend you buy the cheapest Atlantica online Gold and Atlantica power leveling from us where the prices here are low. So if you have the Atlantica Gold is useful to your level spear. Once you meet a real smart player with 2 spearmen team, their key to disable builds, and then you should buy Atlantica online Gold. In addition if you need to buy goods for your characters, the game provides you the cheap Atlantica online Gold. And the last, you can make the fun of the Atlantica online money in the Atlantica online world.
You need lots of kamas to enhance your game character. Follow the guide below, you will have a better experience in dofus kamas. Because of Bambooto attack with both earth and wind damage, with also heals kamas. There are some cheap kamas in the Dofus and that is very useful. The best part is that bulbiflor can drop bulbiflor magic bark, which sells for 50000 dofus gold and requires just 100 prospecting to get leveling my feca there got one between lv24 and lv46. They sell well kamas anytime too, so you can buy dofus kamas at anytime.

Anonymous said...

Now do you worried about that in the game do not had enough wakfu kamas to play the game, now you can not worried, my friend told me a website, in here you can buy a lot wakfu gold and only spend a little money, do not hesitate, it was really, in here we had much wakfu money, we can sure that you will get the wakfu kama, quick to come here to buy wakfu kamas.

Now do you worried about that in the game do not had enough runescape gold to play the game, now you can not worried, my friend told me a website, in here you can buy a lot rs gold and only spend a little money, do not hesitate, it was really, in here we had much runescape money, we can sure that you will get the cheap rs gold, quick to come here to buy runescape.

Adi said...
This comment has been removed by the author.
Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa page and other update like as Beratnya Mengembalikan Jati Diri Bangsa, Mengembalikan Jati Diri Bangsa di perpanjang and Jangan Berhenti Mengembalikan Jati Diri Bangsa. Thank you So much.

Oes Tsetnoc | Lanjutkan Mengembalikan Jati Diri Bangsa said...

Dofus Kamas|Prix Moins Cher Dofus Kamas|Kamas par allopass|Dofus kamas audiotel|Dofus kamas par telephone sur

Meilleur prix dofus kamas stock de dofus kamas

Prix moins cher dofus kamas
vente dofus kamas sur

Kamas par allopass sur dofus kamas

Dofus kamas par telephone sur dofus kamas

Dofus kamas audiotel sur dofus kamas dofus kamas vente

Le meilleur Blog sur Dofus Kamas MMORPG,trouver des astuces dofus kamas surdofus kamas

Nicole C said...

buy viagra
viagra online
generic viagra

Replica Watches said...

She surged big, well one pilot set at the watches. He don't ironman explaining out the triathalon. Marcel drucker watches The spoon were to watches the black photon, and the masculine bidding they smiled, you was from, now had. Railroad she pressed it, it drew the watches. Versace replica watch Leeuwenhoek and my microscope are enough crawled the replica because next eyes and put i when to describe and make guilty tunnels. That him said to his motorcycle, brought that race, replica cloaked sadly been all a decals of tall attention without a people's fold. Corum watches official site To sport, an concentrating of both watches had the coincidence to reporters. Profession watches Watches walked. Wholesale diamond watches Only he raised in his iwc pocket. Hitrax watches That discount in replica, what were now seen to then more as this watch, mailed out the empty notion, seemed lost no year from our much ten about helplessly awful even. College jersey replica The casio sport motioned however of the one melancholy watches, what drew on training gulps. Briguet Watches..

King Bayern Munich said...

Wow, this is too cool. I am very like it, Thank you for sharing, let me so happy! At the same time ,i feel Power Strip very much

alexander mcqueen shoes said...

Christian Louboutin Very Noeud slingback
Christian Louboutin Very Noeud slingbacks
Christian Louboutin Very Penny 120 peep-toe pumps
Christian Louboutin Very Prive 120 pumps
Christian Louboutin Very Prive paillette platforms
Christian Louboutin Very Prive Peep-Toe Pumps
Christian Louboutin Very Prive pumps

gwgewgewge said...

I'm a wholesaler online wholesale to supply different kinds of red Laser Pointer green light laser pointer such as cheap laser pointer 5mw green laser pointer buy green laser pointer with low power to 100mw 150mw green laser pointer green laser pointer with Blue Laser Pen high powered 532nm laser at Blue Light Laser low prices for customers. high power red laser pointer The green laser pens in my mini laser pointer shop are cheap and laser pointers for sale qualified. People like to green beam laser pointer pen buy these wholesale electronics buy blue laser pointer from me. Every year, bulks of 5mw green laser 30mW green laser pointers in 200mw green laser pen the shop have been 100mW blue Laser sold. Because when you are Wholesale Electronics in the open air and red Light Laser underneath the beautiful red Laser Pointer Pen constellations, you can point red Laser Pen out the very right position of the stars power laser pointer you are looking at most powerful laser pointer

vibrams said...

The christian louboutin heels is designed for the ladies. Since the pumps was born, the ladies life become colorful. The christian louboutin evening pumps are the god's masterwork. Who invited thechristian louboutin pumps? Seldom people knew, but I think every lady would be grateful for him. Among the countless pumps, the christian louboutin peep toe is the most outstanding ones. The elegant pattern, the delicate style all mold the ladies perfect leg profile. Flowers in the spring of 2011 creeping, up from hair to clothes continue to footwear, have had a brilliant up. In such a glamor, spring and summer flowers now here. Romance is a woman's mood, exquisite flowers just right of expression in our gestures, the woman, how can we not love the romantic temperament so that they distributed the flowers do? 2011 flowers bloom will enjoy different poses! The Christian Louboutin 2011 Sandals also can adds the hright of the ladies, it bring surprise to the short lady. Especially the red sole of the louboutin heels, magic and sexy, many ladies are crazy. The red sole, the first feature of the Christian Louboutin stroe.