## 2016년 11월 14일 월요일

### Random list and follow up with different commands

Would like to create a app that can do this.
Randomly select an event from a list (e,g, A plus 1, A minus 1, B plus 2, C minus 3)
After the event has been selected, call the value of A,B or C from tinyWebdb and execute the calculation.

use the pick a random item block to pick a rando item from the list
then split the item using the split at spaces block to get another list
now select the first item (which is A, B or C) and use the TinyWebDB.GetValue block to get the value from TinyWebDB
in the TinyWebDB.GotValue block do the calculation

the documentation is here

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 and the aia files for the projects in the book are here:
How to do a lot of basic things with App Inventor are described here:

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, 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.

Taifun

Trying to push the limits of App Inventor!
Snippets and Tutorials from Pura Vida Apps by Taifun.

--
Hi Taifun,

Thanks but i think split at spaces does not solve the problem.
To clarify, from the random list, the "events" are all different. Perhaps i should give a better example.
For example in the list, the events are "Take the value of A and subtract from the value of B", "Add the value of C and the value of A", etc (12 other options)
Once the event has been randomly selected, for example "Add the value of C and the value of A", will need to go to Tiny webdb to getvalue of C and A followed by the addition.
I could do the If, do way for 14 times but was wondering if there are better ways.

--

list 1 to display for the user:
Take the value of A and subtract from the value of BAdd the value of C and the value of A
...

list2:
B - A
C + A
...

and use list 2 for further processing?
use the selection index to get the corresponding item from the second list

and instead the pick a random item block use the random integer block instead to be able to work with the index, see also

Taifun

--

Attached an idea of the list.
getting value from Webdb cause the value of left, right etc can be view from other screens.
unfortunately with this, after running for a few seconds, the numbers go haywire.

--
this looks like a completely different question?

some tips:
disable the clock for the test

#### Top 5 Tips: How to learn  App Inventor

Taifun

--

Thanks.
one of the Do it result came back as
---
Does that mean there is an error in the code even though it is able to run but not getting the correct data?

--

you can't use Do it for local variables

--

### 'Do It' to view procedure results, event arguments and local variables

Although you cannot 'Do It' directly on an argument of a procedure, event, or local variable, you can still view their values.

Create one or more global variables for each of the arguments or local variables.

Then inside the procedure or event blocks assign the value of the arguments or local variables to the global variables.

Place a getter block for the global variables outside the procedure on the Blocks Canvas.

You can then test your app with the emulator or Companion app and device then check the values of the global variables with 'Do It'.

For procedures, you can also test by using 'Do It' directly on a call block to the procedure itself that you have dragged out onto the Blocks Canvas.

Fill in any arguments with test values.

Then right-click and 'Do It' on the procedure call block.

If the procedure returns a value, the value will display, otherwise the global variable's value is now set and can be viewed with 'Do It'.

--

### How To Convert Ascii To Binary?

I Want To Create An Application That Convert Each Individual Letter Of A Word And Converts It Into Binary.

Input = User Text
Process = Conversion Of Text To Words
Output= Displayed As Label

So The Issue With This Is I Don't Know How To Select The Individual Character.

--
use a for each loop and the segment block like this

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 App Inventor, 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.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.

--
Actually there's a way to simplify the spelling process, which in fact I found by mistake some time ago.
Just be aware that the first element of the list is not the first letter of the word. It's just an empty string, which you should eliminate from the list.
And the " " in the AT slot is an empty string, not a space.

--
Also look in the Math section of this FAQ
ABG

--

Thanks For The Help :)

### creat a circular slider

Hello
My knowledge on app inventor is too basic, I´d like to know if is possible to create a circular or semicircular slider.
I think to use a circle as backgroud image on a canvas and an small ball over the image.
my questions are:
1- how to move the ball over the circle?
2- how to draw the arc described by the ball?

I´ll appreciate any help/suggestion.

--
I think this app is exactly what you described.

I am trying to draw a line ovor a circle according the ball position, I will have a min value ( should be 0) and a max value ( less than 360 degrees)
please take a look to the attached image.

--
See the cue stick manipulation code in this doc to be able to drag a line and have it point at the center of a knob. Angry Balls V2 Documentation

Unfortunately, there's nothing in this code to pull it back to the radius of the knob.
You would have to do some trigonometry to adjust its location.

--
Also see this thread, which I found by searching this forum for 'multiturn'....  Multi 'rate' sliders

--
Many thanks for your reply, I will take a look on them.
Regards

--
I am going beter after read the Abraham´s suggestions.
Now I need help or suggetions to resolve:
1- draw a continuos line between initial position and end position (after rotate the sprite.
2- how to update to new painted area when the end position is less than the previous? ( i.e: previous was from 0 to 180 and current from 0 to 150)

--
It's not clear what you want to do.

How about some examples in MS Paint?

--
take a look to this picture, it show how the arc is drawing, it it not a continous line as I expected ..Also I uploaded the blocks image

--
cover it with a stack of overlapping shutters like a Japanese folding fan?

As the angle changes, rotate a growing subset of the shutters out of the way to reveal the ring.

--
It sound good, but How can I do that?

--
Here's how to do it with four sprites covering the ring.
Each sprite is rectangular, and covers one out of the four quadrants of the canvas,

Sprite 1 covers quadrant 1, and lifts as the first 90 degrees of the drag occur.
At 90 degrees, sprite 1 has lifted all the way, leaving quadrant 1 uncovered but
the other 3 quads are covered.

Sprite 2 covers quadrant 2, and is slid left as the second 90 degrees of the drag occur,
until the NW quadrant is completely exposed.

Sprite 3 covers quadrant 3, and is slid down as the third 90 degrees of the drag occur,
until the SW quadrant is completely exposed.

Sprite 4 covers quadrant 4, and is slid right as the fourth 90 degrees of the drag occur,
until the SE quadrant is completely exposed.

The drag logic needs to move a sprite only after all its preceding sprites have been
completely slid off the canvas.

It might be possible to do this entirely without sprites, if they were replaced by 4 dynamically drawn fat lines,
each confined to covering just one quadrant of the circle.

--
thanks for reply. it sound complicated ( for me), but I will try.

--
Even better, I found a pre-coded pie and donut graph example on this board: Line/Radar graphs on canvas *Update* Donut/Pie graphs

It might have parts you can use.

--
It occurred to me that you needed a loop over all angles from 0 to your current angle to fill in the arc.

While I was in there I removed any need for the sprite, in case you decide to draw the circle directly on the canvas.
That would work better for responsive screen sizing than counting pixels.

I also parametrized where i could.
--
thanks for your reply, I will check your suggestions. Before received your reply  I created a donut plot and test with 2 input angles in order to get 4 variable sectors, the issue is that it take more than 3 seconds to plot it.
see the attached files.

--
The double nesting of the loops is a problem.

Not only does it add an order of magnitude to the time needed,
it makes no  sense geometrically.

To cover an area with drawn lines, only a single loop should be needed.

--
I understand, but to how to print for example 2 sectors on the interval o to 180?, Can I do that simultaneously? or first one part the the other ones?

--
on the aia modified by you is possible  to draw in one direction only ( clock wise or counter clockwise) ?

--
understand, but to how to print for example 2 sectors on the interval o to 180?

Take the two values, value(1) and value(2), add them up to get a total.
If you want the total to reach to 180 degrees then each value(n) gets (value(n)*180/total) degrees.
So value(1) occupies 0 to degrees(1), and
value(2) occupies degrees(1) to degrees(1)+degrees(2).

, Can I do that simultaneously?

No
or first one part the the other ones?

Yes

--
on the aia modifed by you is possible  to draw in one direction only ( clock wise or counter clockwise) ?

Isn't that what I already do, going counterclockwise?

--
no it was a curious question only. the value represented on bottom labelbox represent the desired magnitude ( it is OK), but the plot represent the complement of this value.

--