2015년 1월 6일 화요일

coding

trying to code a morse code app for a high school project, but cant figure out how to get a string of text to be translated. I got individual letters to work, but anymore than one letter wont work. is there a way to split the text into individual characters and go from there? keep in mind i am new to app inventor.



Hi Brian.   What are you attempting to do?

Convert a string of text     like a b c d     to dots and dashes   . -   _ . . .   -.-.     or play the sounds of morse code.
What you want to do probably can be done several ways.

1) Using  the text  length block.   Check the entire length of the text.  That tells you how many characters in the screen, then use the length to identify the first character 1, the second character 2  and so on.    If you want dots and dashes,   write out the code in a list, with each character of the alphabet   A, B, C, D ....   then write a second list  with  . -, -...,-.-.,-..    for example, then when you cycle through the length of the screen   use the look up in pairs blocks to associate the two lists, the actual characters and the dot dash character representation.   When list item 1 is  Q  have the App print --.-     and so on.   You could print these to a string by using the Text blocks and a join    or directly to a label.     Remember, you will have to handle spaces between words.

2) Create 26 sound files with the Morse character tones plus punctuation?    Instead of having list 1 point to a dot dash sequence, have it point to a sound file and use the sound file to play it?


The AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page, will help you to learn to use the blocks.

Try some stuff.   If you have issues, return and post a screen capture of your blocks and describe the problem.  Someone will provide advice.

73 and have fun


댓글 없음:

댓글 쓰기