2017년 1월 16일 월요일

AI2 Variables


Variable Blocks

There are five main types of variable blocks:

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
For more help on the topic of global and local variables, take a look at the Global vs Local Variables page.

댓글 없음:

댓글 쓰기