100% found this document useful (1 vote)
463 views

Tutorial Blocks App Inventor

The document provides an overview of the built-in blocks available in the App Inventor blocks editor, describing control blocks, logic blocks, math blocks, text blocks, lists blocks, colors blocks, and variables blocks. It includes descriptions and examples of common block types like if/else, for loops, and procedures.

Uploaded by

Kasparico
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
463 views

Tutorial Blocks App Inventor

The document provides an overview of the built-in blocks available in the App Inventor blocks editor, describing control blocks, logic blocks, math blocks, text blocks, lists blocks, colors blocks, and variables blocks. It includes descriptions and examples of common block types like if/else, for loops, and procedures.

Uploaded by

Kasparico
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

http://appinventor.mit.edu/explore/ai2/support/blocks.

html

App Inventor Built-in Blocks


Built-in blocks are available regardless of which components are in your project. In addition to
these language blocks, each component in your project has its own set of blocks specific to its own events,
methods, and properties. This is an overview of all of the Built-In Blocks available in the Blocks Editor.

Control blocks
Logic blocks
Math blocks
Text blocks
Lists blocks
Colors blocks
Variables blocks
Procedures blocks

Control Blocks
if & if else
for each from to
for each in list
while
if then else
do
evaluate but ignore result
open another screen
open another screen with start value
get start value
close screen
close screen with value
close application
get plain start text
close screen with plain text

if & if else
Tests a given condition. If the condition is true, performs the actions in a given
sequence of blocks; otherwise, the blocks are ignored.

Testes de uma determinada condio. Se a condio for verdadeira,


executa as aes de uma determinada sequncia de blocos; de outro
modo, os blocos so ignorados.
Tests a given condition. If the result is true, performs the actions in the -do
sequence of blocks; otherwise, performs the actions in the -else sequence of
blocks.

Testes de uma determinada condio. Se o resultado for verdadeiro, executa as


aes na seqncia -do de blocos; caso contrrio, executa as aes na seqncia
-else de blocos.
Tests a given condition. If the result is true, performs the actions in the -do sequence
of blocks; otherwise tests the statement in the -else if section. If the result is true,
performs the actions in the -do sequence of blocks; otherwise, performs the actions
in the -else sequence of blocks.

Testes de uma determinada condio. Se o resultado for verdadeiro, executa as


aes na seqncia -do de blocos; caso contrrio, testa a declarao no -else se
seo. Se o resultado for verdadeiro, executa as aes na seqncia -do de blocos;
caso contrrio, executa as aes na seqncia -else de blocos.

The gif below shows how to use the if else mutator block.

Click no azul - e arraste

..

for each from to


Runs the blocks in the do section for each numeric value in the range
starting at from and ending at to, incrementing number by the value
of by each time. Use the given variable name, number to refer to the
current value. You can change the name number to something else if you
wish.
Executa os blocos na seco do para cada valor numrico
na gama de a partir de e terminando no a, incrementando
o nmero por o valor de tempo por cada um. Use o nome
da varivel dada, o nmero para se referir ao valor atual.
Voc pode alterar o nmero de nome para algo mais se
desejar.
for each in list
Runs the blocks in the do section for each item in the list. Use the given
variable name, item, to refer to the current list item. You can change the
name item to something else if you wish.
Executa os blocos na seo de tarefas para cada item na lista.
Use a dada varivel nome, item, para se referir ao item da lista
atual. Voc pode alterar o item de nome para algo mais se
desejar.
while
Tests the -test condition. If true, performs the action given in -do, then tests again. When
test is false, the block ends and the action given in -do is no longer performed.
Testa a condio -teste. Se for verdade, executa a ao dada na -do,
ento testa novamente. Quando o teste for falsa, o bloco termina e as
medidas indicadas na -do no mais realizada.

if then else
Tests a given condition. If the statement is true, performs the actions in the then-return
sequence of blocks and returns the then-return value; otherwise, performs the actions in the
else-return sequence of blocks and returns the else-return value.
Testes de uma determinada condio. Se a afirmao verdadeira, executa
as aes na seqncia, em seguida,-retorno de blocos e retorna o valor, em
seguida,-retorno; caso contrrio, executa as aes na seqncia else-
retorno de blocos e retorna o valor else-retorno.
do
Sometimes in a procedure or another block of code, you may need to do something and
return something, but for various reasons you may choose to use this block instead of
creating a new procedure.
s vezes, em um procedimento ou outro bloco de cdigo, voc pode precisar de fazer
alguma coisa e retornar algo, mas por vrias razes que voc pode optar por usar este
bloco em vez de criar um novo procedimento.

evaluate but ignore result


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.
Fornece uma "tomada isolante" para a montagem de um bloco que tem uma
ficha sua esquerda em um lugar onde no h nenhuma tomada, como um
dos seqncia de blocos na parte fazer de um procedimento ou um bloco if. O
bloco voc se encaixa ser executado, mas o seu resultado retornado ser
ignorado. Isso pode ser til se voc definir um procedimento que retorna um
resultado, mas quiser cham-lo em um contexto que no aceita um resultado.

open another screen


Opens the screen with the provided name.
Abre a tela com o nome fornecido.

open another screen with start value


Opens another screen and passes a value to it.
Abre outra tela e passa um valor a ela.

get start value


Returns the start value given to the current screen.
This value is given from using open another screen with start value or
close screen with value .

Retorna o valor inicial dado tela atual.


Este valor dado a utilizao aberta outra tela com o valor de incio
ou perto da tela com o valor.
close screen
Closes the current screen.
Fecha a tela atual.

close screen with value


Closes the current screen and returns a value to the screen that
opened this one
Fecha a tela atual e retorna um valor para a tela que abriu este

close application
Closes the application.
Fecha a aplicao.
get plain start text
Returns the plain text that was passed to this screen when it was started by
another app. If no value was passed, it returns the empty text. For multiple
screen apps, use get start value rather than get plain start text
Retorna o texto simples que foi passado para esta tela quando foi iniciado
por outro aplicativo. Se nenhum valor foi passado, ele retorna o texto vazio.
Para vrios aplicativos em tela, use Get comear valor, em vez de fazer um
texto incio plain

close screen with plain text


Closes the current screen and passes text to the app that opened
this one. This command is for returning text to non-App Inventor
activities, not to App Inventor screens. For App Inventor Screens, as
in multiple screen apps, use Close Screen with Value, not Close
Screen with Plain Text.

Fecha a tela atual e passa o texto para o aplicativo que abriu este.
Este comando para o regresso de texto para atividades Inventor-
App no, no para telas App Inventor. Para Telas App Inventor,
como em vrios aplicativos em tela, use Fechar tela com valor, no
Fechar tela com texto simples.

============================================================================

Logic Blocks
true
false
not
=

and
or

true
Represents the constant value true. Use it for setting boolean property values of
components, or as the value of a variable that represents a condition.
Representa o valor constante verdade. Use-o para definir valores de
propriedade booleana de componentes, ou como o valor de uma varivel
que representa uma condio.
False
Represents the constant value false. Use it for setting boolean property values of
components, or as the value of a variable that represents a condition.
Representa o falso valor constante. Use-o para definir valores de propriedade booleana de
componentes, ou como o valor de uma varivel que representa uma condio.

Not
Performs logical negation, returning false if the input is true, and true if the input is false.
Executa negao lgica, retornando false se a entrada for verdadeira, e verdadeira se a
entrada falsa.
=
Tests whether its arguments are equal.
o Two numbers are equal if they are numerically equal, for example, 1 is equal to 1.0.
o Two text blocks are equal if they have the same characters in the same order, with
the same case. For example, banana is not equal to Banana.
o Numbers and text are equal if the number is numerically equal to a number that
would be printed with that text. For example, 12.0 is equal to the result of joining
the first character of 1A to the last character of Teafor2.
o Two lists are equal if they have the same number of elements and the
corresponding elements are equal.
Acts exactly the same as the = block found in Math

Testa se os seus argumentos so iguais.


O Dois nmeros so iguais, se eles so numericamente igual, por
exemplo, um igual a 1,0.
o Dois blocos de texto so iguais se eles tm os mesmos caracteres
na mesma ordem, com o mesmo caso. Por exemplo, banana no
igual a banana.
O texto e nmeros so iguais, se o nmero numericamente igual a
um nmero que seriam impressas com texto que. Por exemplo, 12,0
igual ao resultado da juno do primeiro caractere de 1A do ltimo
caractere Teafor2.
O duas listas so iguais, se eles tiverem o mesmo nmero de
elementos e os elementos correspondentes so iguais.
Age exatamente o mesmo que os = bloqueio encontrado em
Matemtica

Tests to see whether two arguments are not equal.


Testes para ver se dois argumentos no so iguais.

And
Tests whether all of a set of logical conditions are true. The result is true if and
only if all the tested conditions are true. When you plug a condition into
thetest socket, another socket appears so you can add another condition.
The conditions are tested left to right, and the testing stops as soon as one of
the conditions is false. If there are no conditions to test, then the result if true.
You can consider this to be a logician's joke.
Testa se tudo de um conjunto de condies lgicas so verdadeiras. O
resultado verdadeira se e somente se todas as condies testadas so
verdadeiras. Quando voc conecta uma condio em thetest socket, outra
tomada aparece assim que voc pode adicionar outra condio. As condies
so testados esquerda para a direita, e os testes pra assim que uma das
condies falsa. Se no houver condies para testar, ento o resultado se
for verdade. Voc pode considerar que isso seja uma piada do lgico.

Or
Tests whether any of a set of logical conditions are true. The result is true if
one or more of the tested conditions are true. When you plug a condition into
thetest socket, another socket appears so you can add another condition. The
conditions are tested left to right, and the testing stops as soon as one of the
conditions is true. If there are no conditions to test, then the result is false.
Testa se qualquer um de uma srie de condies lgicas so verdadeiras. O
resultado verdadeiro se uma ou mais das condies testadas so
verdadeiras. Quando voc conecta uma condio em thetest socket, outra
tomada aparece assim que voc pode adicionar outra condio. As condies
so testados esquerda para a direita, e os testes pra assim que uma das
condies verdadeira. Se no houver condies para testar, ento o
resultado falso.

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Math Blocks
**Note: any Math blocks that have unplugged sockets will read the unplugged spot as a 0.

0 (basic number block) random integer remainder


= random fraction quotient
, random set seed to sin
>, min cos
, max tan
<, sqrt asin
, abs acos
+ - atan
- log atan2
* e^ convert radians to degrees
/ round convert degrees to radians
^ ceiling format as a decimal
floor is a number
modulo convert number

Can't find the math block you're looking for in the built-in blocks?
Some math blocks are dropdowns which means that they can be converted into different blocks. Here's a list
of what is included in each dropdown:
=, , >, , <,

min, max
sqrt, abs, -, log, e^, round, ceiling, floor

modulo of, remainder of, quotient if

sin, cos, tan, asin, acos, atan

convert radians to degrees, convert degrees to radians

Basic Number Block


Can be used as any positive or negative number (decimals included). Double
clicking on the "0" in the block will allow you to change the number.

=
Tests whether two numbers are equal and returns true or false.

Tests whether two numbers are not equal and returns true or false.

>
Tests whether the first number is greater than the second number and returns
true or false.


Tests whether the first number is greater than or equal to the second number
and returns true or false.
<
Tests whether the first number is less than the second number and returns true
or false.


Tests whether the first number is less than or equal to the second number and
returns true or false.

+
Returns the result of adding any amount of blocks that have a number value
together. Blocks with a number value include the basic number block, length of
list or text, variables with a number value, etc. This block is a mutator and can
be expanded to allow more numbers in the sum.

Como usar o plus mutator block

-
Returns the result of subtracting the second number from the first.

*
Returns the result of multiplying any amount of blocks that have a number value
together. It is a mutator block and can be expanded to allow more numbers in the
product.

Com0 usar o Multiply mutator block


/
Returns the result of dividing the first number by the second.

^
Returns the result of the first number raised to the power of the second.

random integer
Returns a random integer value between the given values,
inclusive. The order of the arguments doesn't matter.

random fraction
Returns a random value between 0 and 1.

Retorna um valor aleatrio entre 0 e 1.

random set seed to


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.

Min
Returns the smallest value of a set of numbers. If there are unplugged sockets in
the block, min will also consider 0 in its set of numbers. This block is
amutator and a dropdown

Max
Returns the largest value of a set of numbers. If there are unplugged sockets in
the block, max will also consider 0 in its set of numbers. This block is
amutator and a dropdown.
Sqrt RAIZ QUADRADA
Returns the square root of the given number.

Abs
Returns the absolute value of the given number.

-
Returns the negative of a given number.

log
Returns the natural logarithm of a given number, that is, the logarithm to the base e
(2.71828...).

e^
Returns e (2.71828...) raised to the power of the given number

Round
Returns the given number rounded to the closest integer. If the fractional part is < .5
it will be rounded down. It it is > .5 it will be rounded up. If it is exactly equal to .5,
numbers with an even whole part will be rounded down, and numbers with an odd
whole part will be rounded up. (This method is called round to even.)

Ceiling
Returns the smallest integer that's greater than or equal to the given number.

Floor
Returns the greatest integer that's less than or equal to the given number.

Modulo
Modulo(a,b) is the same as remainder(a,b) when a and b are positive.
More generally, modulo(a,b) is defined for any a and b so that
(floor(a/b) b) + modulo(a,b) = a. For example, modulo(11, 5) = 1,
modulo(-11, 5) = 4, modulo(11, -5) = -4, modulo(-11, -5) = -1.
Modulo(a,b) always has the same sign as b, while remainder(a,b)
always has the same sign as a.

Remainder
Remainder(a,b) returns the result of dividing a by b and taking the
remainder. The remainder is the fractional part of the result multiplied
by b.

For example, remainder(11,5) = 1 because


11 / 5 = 2 15
In this case, 15 is the fractional part. We multiply this by b, in this
case 5 and we get 1, our remainder.

Other examples are remainder(-11, 5) = -1, remainder(11, -5) = 1,


and remainder(-11, -5) = -1.

Quotient
Returns the result of dividing the first number by the second and
discarding any fractional part of the result.

Sin
Returns the sine of the given number in degrees.

Cos
Returns the cosine of the given number in degrees.

Tan
Returns the tangent of the given number in degrees.

Asin
Returns the arcsine of the given number in degrees.

Acos
Returns the arccosine of the given number in degrees

Atan
Returns the arctangent of the given number in degrees.

atan2
Returns the arctangent of y/x, given y and x.

convert radians to degrees


Returns the value in degrees of the given number in
radians. The result will be an angle in the range [0, 360)

convert degrees to radians


Returns the value in radians of the given number in degrees.
The result will be an angle in the range [- , +)

format as decimal
Formats a number as a decimal with a given number of places after the
decimal point. The number of places must be a non-negative integer. The
result is produced by rounding the number (if there were too many places)
or by adding zeros on the right (if there were too few).
is a number

Returns true if the given object is a number, and false otherwise.

convert number
Takes a text string that represents a positive
integer in one base and returns a string that
represents the same number is another base. For
example, if the input string is 10, then converting
from base 10 to binary will produce the string
1010; while if the input string is the same 10, then
converting from binary to base 10 will produce
the string 2. If the input string is the same 10,
then converting from base 10 to hex will produce
the string A.

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Text Blocks
string contains
join split at first
length split at first of any
is empty? split
compare texts split at any
trim split at spaces
upcase segment
downcase replace all
starts at ""

Contains a text string.

This string can contain any characters (letters, numbers, or other special characters). On
App Inventor it will be considered a Text object.

Join
Appends all of the inputs to make a single string. If no inputs, returns an empty
string.
Length
Returns the number of characters including spaces in the string. This is the length of
the given text string.

is empty
Returns whether or not the string contains any characters (including spaces). When
the string length is 0, returns true otherwise it returns false.

compare texts < > =


Returns whether or not the first string is lexicographically <, >, or = the
second string depending on which dropdown is selected.

A string a considered lexicographically greater than another if it is


alphabetically greater than the other string. Essentially, it would come after
it in the dictionary. All uppercase letters are considered smaller or to occur
before lowercase letters. cat would be > Cat.

Trim
Removes any spaces leading or trailing the input string and returns the result.

Upcase
Returns a copy of its text string argument converted to all upper case

Downcase
Returns a copy of its text string argument converted to all lower case

starts at
Returns the character position where the first character of piece first appears
in text, or 0 if not present. For example, the location of ana in havana
banana is 4.

Contains
Returns true if piece appears in text; otherwise,
returns false.
split at first
Divides the given text into two pieces using the location of the first
occurrence of at as the dividing point, and returns a two-item list
consisting of the piece before the dividing point and the piece after the
dividing point. Splitting apple,banana,cherry,dogfood with a comma as
the splitting point returns a list of two items: the first is the text apple and
the second is the text banana,cherry,dogfood. Notice that the comma
after apple doesn't appear in the result, because that is the dividing
point.

split at first of any


Divides the given text into a two-item list, using the first location of
any item in the list at as the dividing point.
Splitting i love apples bananas apples grapes by the list [ba,ap]
would result in a list of two items the first being i love and the
second ples bananas apples grapes.

Split
Divides text into pieces using at as the dividing points and produces a list of
the results. Splitting one,two,three,four at , (comma) returns the list one two
three four. Splitting one-potato,two-potato,three-potato,four at -potato, returns
the list one two three four.

split at any
/sites/all/files/UserGuide/blocks/text/splitAtAny.png"

Divides the given text into a list, using any of the items in at as the dividing
point, and returns a list of the results.

Splitting appleberry,banana,cherry,dogfood with at as the two-element list


whose first item is a comma and whose second item is rry returns a list of
four items: [applebe, banana, che, dogfood,]

split at spaces
Divides the given text at any occurrence of a space, producing a list of the
pieces.

Segment
Extracts part of the text starting at start position and continuing for length
characters.
replace all
Returns a new text string obtained by replacing all occurrences of the
substring with the replacement.

Replace all with She loves eating. She loves writing. She loves coding as
the text, She as the segment, and Hannah as the replacement would result
inHannah loves eating. Hannah loves writing. Hannah loves coding.

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

List Blocks
create empty list pick a random item copy list
make a list index in list is a list?
add items to list select list item list to csv row
is in list insert list item list to csv table
length of list replace list item list from csv row
is list empty remove list item list from csv table
append to list lookup in pairs

Need additional help understanding lists? Check out making lists on the Concepts page.

create empty list


Creates an empty list with no elements.

make a list
Creates a list from the given blocks. If you don't supply any
arguments, this creates an empty list, which you can add elements
to later.
This block is a mutator. Clicking the blue plus sign will allow you to
add additional items to your list.
add items to list
Adds the given items to the end of the list.
The difference between this and append to list is that append to
list takes the items to be appended as a single list
while add items to list takes the items as individual arguments. This
block is a mutator.
is in list?
If thing is one of the elements of the list, returns true; otherwise,
returns false. Note that if a list contains sublists,
the members of the sublists are not themselves members of the list.
For example, the members of the list (1 2 (3 4)) are 1, 2, and the list
(3 4); 3 and 4 are not themselves members of the list.
length of list
Returns the number of items in the list

is list empty?
If list has no items, returns true; otherwise, returns false.

pick a random item


Picks an item at random from the list.

index in list
Returns the position of the thing in the list. If not in the list, returns 0.

select list item


Selects the item at the given index in the given list. The first list item is at
index 1.

insert list item


Inserts an item into the list at the given position

replace list item


Inserts replacement into the given list at position index. The previous
item at that position is removed.

remove list item


Removes the item at the given position.
append to list
Adds the items in the second list to the end of the first list.

copy list
Makes a copy of a list, including copying all sublists.

is a list?
If thing is a list, returns true; otherwise, returns false.

list to csv row


Interprets the list as a row of a table and returns a CSV (comma-
separated value) text representing the row.
Each item in the row list is considered to be a field, and is quoted with
double-quotes in the resulting CSV text. Items are separated by
commas.
For example, converting the list (a b c d) to a CSV row produces ("a",
"b", "c", "d").
The returned row text does not have a line separator at the end.

list from csv row


Parses a text as a CSV (comma-separated value) formatted row to
produce a list of fields.
For example, converting ("a", "b", "c", "d") to a list produces (a b c d).

list to csv table


Interprets the list as a table in row-major format and returns a CSV
(comma-separated value) text representing the table.
Each item in the list should itself be a list representing a row of the
CSV table.
Each item in the row list is considered to be a field, and is quoted with
double-quotes in the resulting CSV text.
In the returned text, items in rows are separated by commas and rows
are separated by CRLF (\r\n).

list from csv table


Parses a text as a CSV (comma-separated value) formatted table to
produce a list of rows, each of which is a list of fields.
Rows can be separated by newlines (\n) or CRLF (\r\n).
lookup in pairs

Used for looking up information in a dictionary-like structure


represented as a list.
This operation takes three inputs, a key, a list pairs, and
a notFound result, which by default, is set to "not found".
Here pairs must be a list of pairs, that is, a list where each
element is itself a list of two elements.
Lookup in pairs finds the first pair in the list whose first element
is the key, and returns the second
element. For example, if the list is ((a apple) (d dragon) (b
boxcar) (cat 100)) then looking up 'b' will return 'boxcar'.
If there is no such pair in the list, then the lookup in pairs will
return the notFound result. If pairs is not a list of
pairs, then the operation will signal an error.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Colors
There are three main types of color blocks:

a color box
make color
split color

basic color blocks

This is a basic color block. It has a small square shape and has a color in the middle that represents the
color stored internally in this block.

If you click on the color in the middle, a pop-up appears on the screen with a table of 70 colors that you can
choose from. Clicking on a new color will change the current color of your basic color block.
Each basic color block that you drag from the Colors drawer to the Blocks Editor screen will display a table
with the same colors when clicked.

make color

make color takes in a list of 3 or 4 numbers. These numbers in this list represent values in an RGB code.
RGB codes are used to make colors on the Internet. An RGB color chart is available here. This first number
in this list represents the R value of the code. The second represents the G. The third represents the B. The
fourth value is optional and represents the alpha value or how saturated the color is. The default alpha value
is 100. Experiment with different values and see how the colors change using this block.

split color

split color does the opposite of make color . It takes in a color: a color block, variable holding a color, or
property from one of the components representing a color and returns a list of the RGB values in that color's
RGB code.

How do colors work in App Inventor?


Internally, App Inventor stores each color as a single number. When you use make color and take in a list as
an argument, internally this list is then converted using App Inventor's color scheme and stored as a number.
If you knew the numbers for the colors, you could even specify what color you wanted something to be by
just setting its Color property to a specific number. If you want to see a chart of colors to numbers, check
out this page.

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Variables
Variable Blocks
There are five main types of variable blocks:

initialize global name to


get
set
initialize local name to in (do)
initialize local name to in (return)
initialize global name to

This block is used to create global variables. It takes in any type of value as an argument. Clicking
on name will change the name of this global variable. Global variables are used in all procedures or events
so this block will stand alone.
Global variables can be changed while an app is running and can be referred to and changed from any part
of the app even within procedures and event handlers. You can rename this block at any time and any
associated blocks referring to the old name will be updated automatically.

Get

This block provides a way to get any variables you may have created.

set to

This block follows the same rules as get . Only variables in scope will be available in the dropdown. Once a
variable v is selected, the user can attach a new block and give v a new value.

initialize Local name to - in (do)

This block is a mutator that allows you to create new variables that are only used in the procedure you run in
the DO part of the block. This way all variables in this procedure will all start with the same value each time
the procedure is run. NOTE: This block differs from the block described below because it is a DO block. You
can attach statements to it. Statements do things. That is why this block has space inside for statement
blocks to be attached.
You can rename the variables in this block at any time and any corresponding blocks elsewhere in your
program that refer to the old name will be updated automatically

initialize Local name to - in (return)

This block is a mutator that allows you to create new variables that are only used in the procedure you run in
the RETURN part of the block. This way all variables in this procedure will all start with the same value each
time the procedure is run. NOTE: This block differs from the block described above because it is a RETURN
block. You can attach expressions to it. Expressions return a value. That is why this block has a socket for
plugging in expressions.
You can rename the variables in this block at any time and any corresponding blocks elsewhere in your
program that refer to the old name will be updated automatically

Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Procedures
A procedure is a sequence of blocks or code that is stored under a name, the name of your procedure block.
Instead of having to keep putting together the same long sequence of blocks, you can create a procedure
and just call the procedure block whenever you want your sequence of blocks to run. In computer science, a
procedure also might be called a function or a method.
Procedure Blocks

procedure do
procedure result

procedure do

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 the block's
mutator button. If you click the blue plus sign, you can drag additional arguments into 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.

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.

procedure result

Same as a procedure do block, but calling this procedure returns a result.

After creating this procedure, a call block that needs to be plugged in will be created. This is because the
result from executing this procedure will be returned in that call block and the value will be passed on to
whatever block is connected to the plug.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

http://kio4.com/appinventorp/index.htm

http://appinventor.mit.edu/explore/index-2.html

http://www.gamedev.net/page/resources/_/technical/artificial-intelligence/chess-programming-part-i-
getting-started-r1014

http://chessprogramming.wikispaces.com/Home

You might also like