|   FORUM      |     Tutoriales    |     KIO4 |      
   Start B4A (Basic4Android) App inventor 2 Arduino
   Elastix - VoIP Things of Windows Interesting Webs  Telecomunications

 


Nuevo concurso para España, Argentina, Brasil, Chile, Colombia, Ecuador, México, Perú y Portugal.

App Inventor 2
Programming mobi
le phones with Android 
by App Inventor 2 - Juan Antonio Villalpando

- Initiation Tutorial App Inventor 2 -

Return to tutorial index

____________________________

46C.- Procedures with Do and Results. (III). Distance between two points in the plane.

 

 ip46C_procedures_3

- Presentation

- Let's see Procedure with Results, to this we can also call functions. We supply some data and gives us a result.

- This we will see is a simple example of Procedure, could enter operations in the same block of Button1 and we would save the block of Procedure, it is simply a didactic example.

- Normally Procedures are used when a part of the code (eg operations) are needed in several blocks, imagine we have 8 - Button and each of them have to perform the operations, it would be easier to create a common block of operations through the procedure and call it from the various buttons, put all operations on all buttons.

- This is to introduce four data corresponding to the coordinates of two points P1(x1, y1) and P2(x2, y2), we call a Procedure called distance and we will result the distance between those two points that are in the same plane.

- The expression for calculation is:

_________________
Design


distancia_puntos.png

_________________
Blocks

                                                                               

__________________________
Comments

- When calling distance, we send the calculation parameters. The Procedure will return the result of that calculation.

- We have created a function called distance, which parameters we supply and return a result.

- If any of the data is entered, the application will fail for lack of data in solving the calculation.

- By Block "Is number?" that is in the part of Mathematics

it has to check, before calling distance if all the variables introduced are numbers.

- If any non - number, a message is displayed warning with Notifier , and operations are not performed.

__________________________________   

 

- My e-mail:
juana1991@yahoo.com
- Who I am. - Cookies. Texts and images propierty autor:
© Juan A. Villalpando
Not copy texts neither images.
We use our own cookies and third-party cookies on our websites to maintain the session and your preferences, customize your user experience and obtain website use statistics.
Si continúa navegando consideramos que acepta su uso. OK    Más información