App Inventor 2
Programming mobile phones with Android
by App Inventor 2 - Juan Antonio Villalpando
- Initiation Tutorial App Inventor 2 -
Return to tutorial index
____________________________
46.- Procedures.
p46_procedimientos
- 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.
_________________
Design
_________________
Blocks
________________________________________________________________________
In this drawing animated look at how variables are added.
Source: AppInventor
____________________________________
Procedure run
This type of procedure is used to change properties, it does not return a result.
______________________
Although it can also be used to change global variables in the example below we have declared one global variable called sum,
each time you call the Add it up procedure, the variable sum will increase its value by 5 and
perform various operations with the Properties.
The variable sumalo, changes when called to the process and we can utilarla elsewhere window.
___________________________
|