|   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

____________________________

46B.- Procedures with Do (II). Operations.

ip46B_procedure_2

- Presentation

A Procedure is a piece of code that can perform an action, this Procedure we can call it from another part of the program.

The usefulness of a Procedure is that sometimes we must make pieces of repetitive codes; with the Procedures we can create a code and call it when it suits us.

They are also commonly used Procedures to improve the presentation of the code.

The Procedure we can supply input values ​​and it will return a result.

Let's see a code using the Pythagorean Theorem Procedure, although in this case is not very useful to use as the code is small to others is not repetitive.

Here is another example of Procedure Run. The variables are global, so we can supply variable and variables we obtain the results that we can use in other blocks, for example in Tags .

- 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.

_________________
Design

_________________
Blocks

_________________________
Comments

- We note that the procedure is called "operations" and the program continues in the next block are performed, in this case the Label3

- The variables are global, that means we can use in any block within the Procedure and beyond.

___________________________

 

- 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