My Blocks#
Introduction#
My Blocks is the equivalent to functions in Python. My Blocks group code into reusable, efficient sections of code designed to perform a specific task. My Blocks can be called multiple times within a program, making code organization easier, and helping to avoid repeated code.
definir myBlock
myBlock
Parameters |
Description |
|---|---|
block name |
A name you give to your My Block. |
parameters |
Optional. Variables that accept input values when the function is called, allowing data to be passed into the function. It can be number or Boolean. |
Defining and Calling My Blocks#
My Blocks#
If a My Block does not require input, you can define it without parameters.
When started, calls a custom block named ‘greeting’ to print ‘Hello!’ on the screen.#
definir greeting
[Define a My Block to display a message.]
imprimir [Hello!] en la consola ◀ y coloque el cursor en la siguiente fila
cuando empezó
[Call a My Block to display the message.]
greeting
My Blocks with Parameters#
You can also add parameters to My Block, which let you pass in information the My Block needs to work.
When started, calls a custom block ‘named_greeting’ with a parameter. It prints “Hello, ’ followed by the given name on the screen.#
definir repetitions (number) :: custom
[Define a My Block with a parameter.]
repetir (number)
incrementar la posición [brazo v] en x:[100] y:[0] z:[0] [mm v] ▶
cuando empezó
[Call a My Block start incrementing.]
repetitions [4]