(MAD) Commands and Expressions Lesson
Commands and Expressions
When an event handler fires, it executes a sequence of commands in its body. A command is a block that specifies an action to be performed. Most command blocks are purple in color.
A call block command is generated by a procedure (function or method) that has been created. The call block is used to invoke the procedure. As we have learned previously, procedures (functions/methods) have a parameter where we can supply arguments to completely specify information the procedure needs to execute.
The set command is used to set information.
Notice the blocks have sockets on the right edge of the command for supplying the input values. These inputs can be expressions to denote a particular value or strings.
Expressions
Expressions are found in the math block editor. They can be used for assigning values, creating basic arithmetic expressions with addition, subtraction, multiplication, division and modulus.
Remember the order of operation when creating expressions.
- P - Parentheses first
- E - Evaluate Exponents
- M - D - M - Multiply, divide, modulus
- A - S - Add, subtract
- Work left to right
We know in programming that Multiplication, Division and Modulus have the same precedent working left to right. So, I've added an acronym M for Modulus.
Please Excuse My Dear Magnificent Aunt Sally
[CC BY 4.0] UNLESS OTHERWISE NOTED | IMAGES: LICENSED AND USED ACCORDING TO TERMS OF SUBSCRIPTION