Google App Inventor Wiki
Advertisement

Below is a list of all the blocks in the Blocks Editor. Blocks in the editor snap together like a jigsaw puzzle to create easily edited and understandable code for the app. There are seven block categories, not including the "My Blocks" section

Definition Blocks[]

Main Article: Definition Blocks

Definition blocks define variables and can create procedures. There are 5 definition blocks.

Procedure[]

Procedure

The basic Procedure block

Main Article: Procedure

Collects a sequence of blocks together into a group. You can then use the sequence of blocks repeatedly by calling the procedure. If the procedure has arguments, you specify the arguments by using name blocks. When you create a procedure, App Inventor automatically generates a call block and places it in the My Definitions drawer. You use the call block to invoke 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. Procedure names in an app must be unique. App Inventor will not let you define two procedures in the same app with the same name. You can rename a procedure at any time while you are building the app, by changing the label in the block. App Inventor will automatically rename the associated call blocks to match.

ProcedureWithResult[]

ProcedureWithResult

The Basic ProcedureWithResult

Main Article: ProcedureWithResult

Same as a procedure block, but calling the procedure returns a result. After the procedure executes, the result is returned to the block connected to the return socket.

Variable[]

Variable

The basic Variable block

Main Article: Variable

Creates a value that can be changed while an app is running, and gives that value a name. Variables are global in scope, which means you can refer to them from any code in the app, including from within procedures.

When you create a new variable block, App Inventor chooses a unique name automatically. You can click on the name and type to change it. Variable names in an app must be unique. App Inventor will not let you define two variables in the same app with the same name.

When you create a variable, App Inventor will automatically create two associated blocks, and place them in the My Definitions drawer:

  • The global block gets the value of the variable.
  • The set global block changes the value of the variable.

You can rename a variable at any time while you are building the app, and the associated blocks will be renamed automatically.

|[]

Vertcal line

Main Article: Vertical Line

This block provides a "dummy socket" for fitting a block that has a plug on its left into a place where there is no socket, such as one of the sequence of blocks in the do part of a procedure or an if block. The block you fit in will be run, but its returned result will be ignored. This can be useful if you define a procedure that returns a result, but want to call it in a context that does not accept a result.

Text Blocks[]

Main Article: Text Blocks

Text blocks create, manipulate and destroy text. Text is usually reserved for displayed UI as it can't really be used effectively internally. There are 19 text block types.

Text[]

Main Article: Text

The basic building block of text. This block contains a text string.

=[]

Main Article: =

The equals sign, which also appears in the Math Blocks and the Logic Blocks, returns a value of true if the two arguments are the same. This extends to not only mathematical equations but to text, Component properties and logic. Two mathematical expressions are the same if their end results are equivalent (the same). Two texts are equal if the characters in both are exactly the same. The equals sign can also be used to check if a component is a particular color or size.

Join[]

Main Article: Join

The join block is used, quite literally, to stick two text strings or values together.This can be used to include a variable within a text on the app. The text string in the left slot will be directly to the left of whatever is on the right.

Make Text[]

Main Article: Make Text

The make text block is like a join block on a massive scale. Each time a new value or text is added, the block "grows" a new slot for another value. Make text blocks can grow to immense proportions this way.

Length[]

Main Article: Length

The length block reports the length of the given string.

Text<[]

Main Article: Text(Less Than)

The text< block reports a True/False Statement base on whether or not the first character of the first (top) text string is alphabetically lesser than the first character of the second (bottom) text string. Uppercase letters precede lowercase ones. If they are the same, the block judges if the first string is shorter.

Text=[]

Main Article: Text=

The text= block reports a True/False Statement based on if the two text strings are identical. It basically works the same way as the = block.

Text>[]

Main Article: Text(Greater Than)

The text> block reports a True/False Statement base on whether or not the first character of the first (top) text string is alphabetically greater than the first character of the second (bottom) text string. Uppercase letters precede lowercase ones. If they are the same, the block judges if the first string is longer.

Trim[]

Main Article: Trim

The trim block returns the given text string with any leading or trailing spaces removed. For example (underscores are spaces in this example): _example_text_ becomes example_text.

Upcase[]

Main Article: Upcase

The upcase block returns a copy of the given string in all capital letters. For example: sample text becomes SAMPLE TEXT.

Downcase[]

Main Article: Downcase

The upcase block returns a copy of the given string in all lowercase letters. For example: SAMPLE TEXT becomes sample text.

Starts at[]

Main Article: Starts at

The starts at block returns the numbered position of the start of the "piece" in the "text". "0" is returned if the "piece" does not exist in the "text".

Contains[]

Main Article: Contains

The contains block returns a value of true if the text contains the piece.

Split at First[]

Main Article: Split at First

The split at first block splits the text into a two- element list at the first instance of the at value.

Split at First of Any[]

Main Article: Split at First of Any

The split at first of any block splits the text into a list at any of the at values. Like the Make Text block these "grow" an extra input slot in order to accomodate an infinite number of at values.

Split[]

Main Article: Split

The split block splits the text value into a list at every instance of the at value.

Split at Any[]

Main Article: Split at Any

The split at any block splits the text into a list at every instance of each at value. Like the Make Text block these "grow" an extra input slot in order to accomodate an infinite number of at values.

Split at Spaces[]

Main Article: Split at Spaces

The split at spaces block splits the text into a list at every instance of a space.

Segment[]

Main Article: Segment

The segment block extracts a segment of the text value starting at the start value and ending at the end value.

List Blocks[]

Main Article: List Blocks

List blocks create, and manipulate lists which can be combined with the for each block to do a set series of operations on every value in the list.

Make a List[]

Main Article: Make a List

The make a list block creates a list from the given blocks on the right-hand side. If no data is given, the block will create an empty list which you can add to later.

Select List Item[]

Main Article: Select List Item

The select list item block selects the item with the index number from the list specified in the list socket. The first index number is 1, proceeding accordingly.

Replace List Item[]

Main Article: Replace List Item

The replace list item block replaces the item at the specified index slot in the specified list with the replacement value. The first index number is 1, proceeding accordingly.

Remove List Item[]

Main Article: Remove List Item

The remove list item block does, as the name suggests, remove the selected item from the selected list. The selection of which is done in the same manner as the Select Item List block, and the Replace Item List block.

Length of List[]

Main Article: Length of List

The length of list block returns the number of items in the specified list.

Append to List[]

Main Article: Append to List

The append to list block adds the items from list2 to the end of list1.

Add Items to List[]

Main Article: Add Items to List

The add items to list block adds the arguments to the specified list. This block will add another item socket every time one is filled, making it essentially infinite.

Is in List?[]

Main Article: Is in List?

The is in list? block returns a True/False Statement, returning true if the give nitem is in the given listn not including Sublists.

Position in List[]

Main Article: Position in List

The position in list block returns the index number of the specified thing. This can be combined with any of the blocks asking for an index value, if the programmer is so inclined to not use the number.

Pick Random Item[]

Main Article: Pick Random Item

The pick random item block will select a value at random from the specified list.

Is List Empty?[]

Main Article: Is List Empty?

The is list empty? block returns true if the specified list is indeed empty, false if otherwise.

Is a List?[]

Main Article: Is a List?

The is a list? block returns true if the specified component is a list, false if otherwise.

Math Blocks[]

Main Article: Math Blocks

The Math blocks handle mathematical functions suitable for calculator applications.

Number[]

Main Article: Number

The number block is the basis of math functions defining an integer suitable for math functions.

>[]

Main Article: Greater Than

The > block returns a result of true if the left value is mathematically greater than the right value.

<[]

Main Article: Less Than

The < block returns a result of true if the left value is mathematically less than the right value.

>=[]

Main Article: Greater Than or Equal To

The >= block returns a result of true if the left value is mathematically greater than or equal to the right value.

<=[]

Main Article: Greater Than or Equal To

The <= block returns a result of true if the left value is mathematically less than or equal to the right value.

=[]

Main Article: =

The equals sign, which also appears in the Text Blocks and the Logic Blocks, returns a value of true if the two arguments are the same. This extends to not only mathematical equations but to text, Component properties and logic. Two mathematical expressions are the same if their end results are equivalent (the same). Two texts are equal if the characters in both are exactly the same. The equals sign can also be used to check if a component is a particular color or size; for example: component.Color = Color.

+[]

Main Article: +

The + block adds the two inputs and returns the sum. This is a basic math operator.

-[]

Main Article: -

The - block subtracts the second input from the first and returns the difference. This is a basic math operator.

x[]

Main Article: x

The x block multiplies the two inputs and returns the product. This is a basic math operator.

/[]

Main Article: Divide

The / block divides the first input by the second and returns the quotient. This is a basic math operator.

sqrt[]

Main Article: sqrt

The sqrt block returns the square root of the value.

random fraction[]

Main Article: random fraction

The random fraction block returns a random value between 0 and 1.

random integer[]

Main Article: random integer

The random integer block returns a random integer between the two specified values including the two values themselves.

random set seed[]

Main Ariticle: random set seed

Use this block to generate repeatable sequences of random numbers. You can generate the same sequence of random numbers by first calling random set seed with the same value. This is useful for testing programs that involve random values.

References[]

  1. Definition Blocks - App Inventor for Android
  2. Math Blocks - App Inventor for Android

Tutorial Sites[]

  1. App Inventor Tutorials, Sample Apps, Tips and Tricks
Advertisement