to-morse.bas
is a LibreOffice macro that translates text in a spreadsheet cell to its representation in Morse Code.
To add to-morse.bas
to the pangram.ods
LibreOffice spreadsheet included in this repository I followed these steps:
- Tools → Macros → Organize Macros → Basic…
- New → Module1
- OK. Paste the raw contents of to-morse.bas over the program skeleton in the IDE.
- Save & close
- Add
=ToMorse()
to the spreadsheet
You may find that you need to Enable Macros
depending on your security settings.
I'd normally program something like this in Python, JavaScript, or Ruby but I was working on dialogue for a moving image project and a spreadsheet seemed like the most natural tool at my disposal for generating drafts. Rather than uploading contents cell-by-cell into an online Morse Code converter this function seemed like the best way to go.
I haven't coded in any variant of BASIC for decades.
I did have a Novice class amateur radio license in my youth, and I've retained some of that in brain and in muscle memory, but I've found that having a dit-dah script is a good fallback.
Unknown. LibreOffice derives from OpenOffice so I'd expect it to work there. I don't have access to a copy of Excel. Google Sheets seems not to import the macro along with pangram.ods
. Numbers does not open .ods
files directly at all.
I welcome pull requests that insert succinct descriptions of using this macro with spreadsheet software other than LibreOffice. Thanks in advance!
Due to time limitations, not all punctuation marks are translated. I welcome pull requests to add ones I've missed. Please note that non-breaking spaces are used within the Morse Code representations and to bracket spacing; I strongly encourage you to use an IDE that explicitly identifies whitespace characters. (I used WebStorm, one of JetBrains' offerings, but it's a common option within IDEs.)
It'd be handy if the macro could programmatically recognize certain prosigns that use an overline text decoration, and subsequently compress multiple codes into a single one. I'm not clear if LibreOffice has that capability.
It'd be nice to be smarter about spacing when cell content wraps, i.e., it'd be great if the Morse Code cell looked left-justified.