2017년 1월 11일 수요일

Multiple lines of text


Is it possible to have the written text go to the next line after every two words. For example, if I write, " I read the whole book" into the blocks and it automatically puts it into three lines like this:
I read the whole book

--
Start with an empty string called result and an empty list called Words.

Set Words to split (your input text) at " ".
That will give you a list of text pieces, one per word.

Now build up your result, word by word.
As you add each word to result, follow it with either a blank or a \n depending on whether or not the index is odd or even, respectively.

FOR EACH n = 1 to length(Words)
  set result = JOIN(result, 
                               SELECT ITEM n FROM Words,
                               IF mod(n,2) = 1 THEN " " ELSE "\n")
END FOR

-- 
Is this something I can do with the blocks of MIT appinventor? Its seems like this is JavaScript and I'm not too familiar with that. Seems confusing with the blocks.

-- 
this is some pseudo code
you will have to use the corresponding App Inventorblocks

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of AppInventor, then try something and follow the
 Top 5 Tips: How to learn App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

-- 

댓글 없음:

댓글 쓰기