• Procedure Blocks

    A procedure is a sequence of blocks or code that is stored with a name, the name of your procedure block. Instead of having to keep doing the same long sequence of blocks, you can create a procedure and just call the block of procedures whenever you want that sequence of blocks to run. In computer science, A procedure can also be called a function or a method.
    • Procedure - Do
    • Gather a sequence of blocks in a group, you can use the sequence of blocks repeatedly calling the procedure.
    • If the procedure has arguments, specify the arguments using the button of the mutator of the block. If you click on the blue plus sign, You can drag additional arguments to the procedure.
    • When you create a new procedure block, App Inventor chooses a unique name automatically. You can click on the name and type to change it. The names of the procedures in an application must be unique. App Inventor will not allow you to define two procedures in the same application with the same first name. You can change the name of a procedure at any time while you are building the application, changing the label in the block. App Inventor will automatically change the name of the associated call blocks to match.
    • When you create a procedure, App Inventor automatically generates a call block and place it in the drawer of My Definitions. Use the call block to invoke the procedure.
    • Procedure - Result
    • Same as a previous procedure, but call this procedure returns a result.
    • We can change the name, by clicking on it.
    • We can also call the procedure using this function
    • Example
    • Let's see an example, in this case we have declared a variable called name and go to create two procedures, one to change the variable 'name' with 'Change_value' and another to obtain it 'Get_value', these would be the typical get & set of a variable in a class.
    • Our global variable 'name' is empty, so we can call procedure 'Change_value' and add one.
    • The value now named, will be Block2Code. If we want to get it, it's enough with calling the procedure 'Get_value'. This will return a text string with the word Block2Code.
    • If you need more information you can go to the documentation official MIT App inventor