As the title says, I've made a program that will convert inputted text into Morse! Not only that, but with the power of ASM, it will flash the screen according to what text you entered! You can also save your Morse for use later. Note: This requires CE OS 5.2 or above to run.

This can take every (uppercase) letter and number. You are allowed to input whitespace however I don't really know how to represent that so I just made a slight pause.


The GIFs are weird since I couldn't use CEmu because it doesn't record screen brightness changes so I had to revert to other methods.

Finished! Download Here!

This program won the October 2017 POTM!!! Thank you everyone!
Sounds cool!, I suggest a few optimizations, and the use of this. Also, I think CEmu does do brightness. Check and see., but I'm using a old version of CEmu.
SM84CE wrote:
Sounds cool!, I suggest a few optimizations, and the use of this.


Telling people to use your program generally doesn’t make them want to use your program Wink

Here’s my optimized program, which is much smaller. (I’m not sure, but I think it’s quite a few bytes smaller and noticibly faster)

I removed the assorted lowercase letters, as they are 2 bytes, but uppercase letters are 1 byte, and if your program doesn’t support lowercase letters on input, don’t use them otherwise!

I also made some strings smaller by rephrasing them to be several bytes shorter.


Code:
ClrHome
Disp "SETTING UP...

DelVar L₁DelVar L₃
36→dim(L₁
1→dim(L₃
"L6
2→dim(L₆
Fill(1,L₆
"STORES MORSE (nums FIRST (0 is last num))
{0,0,0,0,1,2,2,2,2,1,1,2,2,2,1,1,1,2,2,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1,2,2,1,1,1,2,2,2,1,1,2,2,2,2,1,2,2,2,2,2,1,2,0,0,0,2,1,1,1,0,2,1,2,1,0,2,1,1,0,0,1,0,0,0,0,1,1,2,1,0,2,2,1,0,0,1,1,1,1,0,1,1,0,0,0,1,2,2,2,0,2,1,2,0,0,1,2,1,1,0,2,2,0,0,0,2,1,0,0,0,2,2,2,0,0,1,2,2,1,0,2,2,1,2,0,1,2,1,0,0,1,1,1,0,0,2,0,0,0,0,1,1,2,0,0,1,1,1,2,0,1,2,2,0,0,2,1,1,2,0,2,1,2,2,0,2,2,1,1,0,1→L₂

Menu("TEXT TO MORSE CONVERTER!","CONVERT TEXT TO MORSE",T,"LOAD MORSE",L,"QUIT",99

Lbl T
ClrHome
":→Str0
Input "ENTER TEXT: ",Str1
Disp "CONVERTING...
For(A,1,length(Str1
sub(Str1,A,1→Str2
If Ans≠" " and Ans≠"0
Then
10+inString(“ABCDEFGHIJKLMNOPQRSTUVQXYZ”,Str2→θ
For(B,5θ,5θ+5
L₂(B→L₃(1+dim(L₃
End
Else
“One space
If Str2="
augment(L₃,{2→L₃
If Str2="0
augment(L₃,{2,2,2,2,2→L₃
End
End
".-→Str3
For(A,1,dim(L₃

If L₃(A
Str0+sub(“.-“,L₃(A),1→Str0
End
Goto D

Lbl L
Disp "LOADING Str0...
For(A,1,length(Str0
sub(Str0,A,1
inString(“.-“,Ans→L₃(1+dim(L₃
End

Lbl D
ClrHome
“Used tokens Repeat and Stop to save size.
Disp "DONE! STORED IN Str0","FLASH MORSE?","1: YES, ONCE","2: YES, Repeat","3: No, Stop"
Input "",A

"Check if quit is selected
If A=3
Goto 99

Lbl F
ClrHome
255
Asm(prgmDARKNESS
For(A,1,dim(L₃
If L₃(A
Then
0
Asm(prgmDARKNESS
Wait (L₃(A)/4)
End
255
Asm(prgmDARKNESS
Wait .2
If getKey=45

End
If A=2
Goto F
"resets the brightness
200
Asm(prgmDARKNESS
Lbl 99
Str0
nothing wrong in giving some advice for optimizations, is there??
And I'm the only one who thought of/ implemented this, even though the DelVar command and many other tips have been there, I was the only one (that I know of) to put them in a program
SM84CE wrote:
Sounds cool!, I suggest a few optimizations, and the use of this.
I'll take a look, as _iPhoenix_ pointed out I may end up not using it, but I'm always open to optimizations!

_iPhoenix_ wrote:
Here’s my optimized program, which is much smaller. (I’m not sure, but I think it’s quite a few bytes smaller and noticibly faster)

I removed the assorted lowercase letters, as they are 2 bytes, but uppercase letters are 1 byte, and if your program doesn’t support lowercase letters on input, don’t use them otherwise!

I also made some strings smaller by rephrasing them to be several bytes shorter.


Code:
ClrHome
Disp "SETTING UP...

DelVar L₁DelVar L₃
36→dim(L₁
1→dim(L₃
"L6
2→dim(L₆
Fill(1,L₆
"STORES MORSE (nums FIRST (0 is last num))
{0,0,0,0,1,2,2,2,2,1,1,2,2,2,1,1,1,2,2,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1,2,2,1,1,1,2,2,2,1,1,2,2,2,2,1,2,2,2,2,2,1,2,0,0,0,2,1,1,1,0,2,1,2,1,0,2,1,1,0,0,1,0,0,0,0,1,1,2,1,0,2,2,1,0,0,1,1,1,1,0,1,1,0,0,0,1,2,2,2,0,2,1,2,0,0,1,2,1,1,0,2,2,0,0,0,2,1,0,0,0,2,2,2,0,0,1,2,2,1,0,2,2,1,2,0,1,2,1,0,0,1,1,1,0,0,2,0,0,0,0,1,1,2,0,0,1,1,1,2,0,1,2,2,0,0,2,1,1,2,0,2,1,2,2,0,2,2,1,1,0,1→L₂

Menu("TEXT TO MORSE CONVERTER!","CONVERT TEXT TO MORSE",T,"LOAD MORSE",L,"QUIT",99

Lbl T
ClrHome
":→Str0
Input "ENTER TEXT: ",Str1
Disp "CONVERTING...
For(A,1,length(Str1
sub(Str1,A,1→Str2
If Ans≠" " and Ans≠"0
Then
10+inString(“ABCDEFGHIJKLMNOPQRSTUVQXYZ”,Str2→θ
For(B,5θ,5θ+5
L₂(B→L₃(1+dim(L₃
End
Else
“One space
If Str2="
augment(L₃,{2→L₃
If Str2="0
augment(L₃,{2,2,2,2,2→L₃
End
End
".-→Str3
For(A,1,dim(L₃

If L₃(A
Str0+sub(“.-“,L₃(A),1→Str0
End
Goto D

Lbl L
Disp "LOADING Str0...
For(A,1,length(Str0
sub(Str0,A,1
inString(“.-“,Ans→L₃(1+dim(L₃
End

Lbl D
ClrHome
“Used tokens Repeat and Stop to save size.
Disp "DONE! STORED IN Str0","FLASH MORSE?","1: YES, ONCE","2: YES, Repeat","3: No, Stop"
Input "",A

"Check if quit is selected
If A=3
Goto 99

Lbl F
ClrHome
255
Asm(prgmDARKNESS
For(A,1,dim(L₃
If L₃(A
Then
0
Asm(prgmDARKNESS
Wait (L₃(A)/4)
End
255
Asm(prgmDARKNESS
Wait .2
If getKey=45

End
If A=2
Goto F
"resets the brightness
200
Asm(prgmDARKNESS
Lbl 99
Str0

Sadly, the code doesn't work perfectly (It keeps adding an 'A' at the end of every code) but I should be able to fix it. Smile


Code:
10+inString(“ABCDEFGHIJKLMNOPQRSTUVQXYZ”,Str2→θ

0x5, I knew there had to be a better way than what I was doing! Very Happy

A few things I'm confused by:

Code:
“One space
If Str2="
augment(L₃,{2→L₃

I'm a little confused why you put the " (the top line) there, couldn't it be removed?


Code:
sub(Str0,A,1
inString(“.-“,Ans→L₃(1+dim(L₃

The only part here I'm confused by is the →L₃(1+dim(L₃
by the looks of it, it is going to store the . or - into '1+the entire length of L₃' position of L₃ . Could you explain how this works?

Thanks _iPhoenix_! This really helps!
Ok, here’s my explanation:

The A at the end is there because I am a failure at typing when I am on a plane that is trying to land.

The top line is my comment. I was saying that there is one space there, as it would not be immediately obvious to someone visually copying the code. So of course, it can be removed (I am assuming you are talking about the “One space)

Here’s that last one, translated from TI-BASIC to English:

Get the A’th character in Str0
Find that character’s position in the string “.-“ (return 0 if it is not in the string), and store that number to the spot after the last element in the list.

inString() is pretty much the opposite of sub(), but not really.

inString(string, substring,(optional) n) returns the value of the first character of the first instance of substring past position n in string

In your program, you “paired” the ‘.’ character with the value 1. Because the initial sub() command already gave me my substring, which I knew had a length of 1, I put it at the front of string, where it will return 1 if it is passed as string. So, my inString() command so far looks like this:
inString(“.

Also, you had a “-“, which you paired with 2. I put this in the second position in my string, so that if it was the substring, it would return 2.
At this step, the inString command looks like this:
inString(“.-

Because all other characters are supposed to be 0 and inString automatically returns 0 if the character isn’t in the string, I can finish up my inString() command by inputting the substring, giving me the full command.

I’m essentially “undoing” the sub() command that I used to turn the values in the “database” list into .’s and -’s. Take note that I used the same string in my sub() command.


Code:
If L₃(A
Str0+sub(“.-“,L₃(A),1→Str0


I’ll explain the above code, too, and why it is the opposite of my inString() command.

The If statement works the same as the last part of the inString(), where if the substring isn’t in the string, the command returns 0. The If statement ignores these 0’s, and prevents a crash, too.

The sub() command uses the same string as the inString, and I explained why to a sufficient extent. Hopefully.

Put more generally, if the string in sub(string, position, length) is the same as the string in inString(string, substring,(optional) n), and string does not contain any duplicate substrings of length length, then inString(string,sub(string,position,length)) will return position.

I really, really hope this makes sense. I hate BBcode now. Expecially italics.

Now, let’s explain the original question!

Here’s something cool with lists:
If you have a list of size n, and n<999, you can store a value to the (n+1)th position in the list, and the list’s size will expand to accommodate that value.

For example, the following code is valid:

Code:
1->dim(L1
1->L1(1
2->L1(2

but the following code should give a (domain? dimension? divide by zero? I don’t know/I’m too tired) error:

Code:
1->dim(L1
1->L1(1
2->L1(3


Instead of using augment to append a one-element list, I store it to this spot.

Time to ICE my fingers! (Really, really bad pun.)

Typed on an iPhone... OuchI really hope this helps.


Edit: I’ll look for the bug with the A.
Very nice work TheLastMillennial! It looks like some pretty wild code going one there; keep it up Smile

SM84CE wrote:
nothing wrong in giving some advice for optimizations, is there??
And I'm the only one who thought of/ implemented this, even though the DelVar command and many other tips have been there, I was the only one (that I know of) to put them in a program

Ahm. Razz
http://www.ticalc.org/archives/files/fileinfo/303/30339.html
http://www.ticalc.org/archives/files/fileinfo/313/31310.html
http://www.ticalc.org/archives/files/fileinfo/373/37367.html
http://www.ticalc.org/archives/files/fileinfo/267/26711.html
http://www.ticalc.org/archives/files/fileinfo/411/41163.html
http://www.ticalc.org/archives/files/fileinfo/352/35210.html
Anyway suggestions are always welcome Smile
err... I didn't check ticalc, but I stand corrected. I was talking about cemetech, of course Smile
Hey I figured out the bug! The For( loop was looping one too many times. Laughing
Anyways, I'm currently capturing the screenshots and I'm hoping to get this uploaded soon! Very Happy


Uploaded! I'll edit the first post when it is accepted!
This is a very cool idea Smile.
Hey small update.
v 3.20
I swapped the light changing program from prgmDARKNESS to prgmSETLCD since I've been using prgmSETLCD more than prgmDARKNESS. And the fewer programs, the better!
Included brightness saving feature so when you quit, your original brightness is restored.
I've uploaded to the archives and I'm waiting for it to be accepted.
EDIT: It's been accepted! Download here! Very Happy
I dunno why, out of all the other projects I've been doing, I decided to pick up this thing again. I guess I was tired of not finishing anything so I did something I could finish.

As it turns out, my old program's flash timing was completely wrong, for example, each dah is suppose to be three dits, the old program's dah was only 2 dits. So in v 3.47 I fixed that along with the time between each element, the time between each word, and the time between repeating phrases. While I was doing that, I also decided to add support for white space and periods in my converter.

Well it's uploaded to the Archives queue, hope you enjoy it!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement