Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Text Parsing - splitting a word into individual letters. (Morse Code)

1,126 views
Skip to first unread message

Elizabeth Dillard

unread,
May 18, 2015, 11:01:21 AM5/18/15
to mitappinv...@googlegroups.com
Question on parsing

I have a student that wants to translate from english to morse code.  In this case you would need to read a word letter by letter.
I can see how to parse a string into words by splitting on spaces.  I don't know how to parse a word into individual letters.  

Could I move the individual word to a list of letters and loop through the list - how to do it though?  
If I was doing it in another language I would get the length of the string,   Then in a loop I could look at each letter in the string until the # letter in the string = length of string.

I.E

For x = 1 to Length of list
     Look at the xth letter in the list
Next x


I know how to do this in other languages - but not in App Inventor.
Some help would be greatly appreciated.

SteveJG

unread,
May 18, 2015, 11:20:40 AM5/18/15
to mitappinv...@googlegroups.com
The advanced tutorial demonstrate several ways to get 'Morse' code in an App Inventor app:

What the student needs to do depends on how he/she wants to display the code ... does the student want to hear it?     Does he want the app to display the dots and dashes ...for instance for the letter A, does the student want to display . -     and for B display -...    (which is very simple).  AND depends on how the student wants to enter the letter than needs to be 'translated' into morse code.

Examine the code, find the example needed and only code that.

Try some blocks.....   Does this help?

Regards,
Steve 


SteveJG

unread,
May 18, 2015, 11:57:02 AM5/18/15
to mitappinv...@googlegroups.com
In addition to the comments above, here is on example how to do exactly what you asked for ... how to split a string into its individual characters 

When using this in practice, eliminaet the TextBox block in the button.  There are other ways.

and regarding"Letter for letter would not be hard.  He wants to type in words and have it parse the words and convert it."    above is a partial solution; a more complete solution is in the tutorial.  For future, Betsy, we ask that the conversation stay in the forum...not by eMail ... Thanks.


Regards,
Steve

Elizabeth Dillard

unread,
May 18, 2015, 12:16:43 PM5/18/15
to mitappinv...@googlegroups.com
Thanks SteveJG

Nope - sorry that's not what I needed. - For your suggestion I could use parallel lists and translate that way - that's easy once I get down to one letter - agreed.

My question is dealing with 1 word.  So take a phrase - and split it into words
"This is a phrase"  --  split in to words - use split and a space - put words into a list.  Still no problem.

Problem - how to split a word into letters
make "This"  equal to a list of letters - "T" "h" "i" "s"
Once I have a list of letters I can read through that list and translate the individual letters into morse code.


Elizabeth Dillard

unread,
May 18, 2015, 12:18:29 PM5/18/15
to mitappinv...@googlegroups.com

Elizabeth Dillard

unread,
May 18, 2015, 12:20:56 PM5/18/15
to mitappinv...@googlegroups.com
Steve - sorry - it looked like an empty box - that looks great!!
Reply all
Reply to author
Forward
0 new messages