In the previous lesson we learned how to define and "call" a re-usable module of code, i.e., a function. Sometimes when we call a function (tell RoboBlocky to execute the code inside the function), it is useful to send additional information to the function. For example, the createSquare function in the previous lesson had the robot draw squares with side length 6. But it would make the function even more useful if we could send it any side length we wanted, rather than it just being fixed at 6. To do this, we can create functions with input values. In programming terminology, these input values are called "parameters" or "arguments", and we talk about "passing a parameter" or "passing an argument" to the function. In other words, we send ("pass") an input value to the function for it to use when its code is executed. We add input values to a RoboBlocky function by clicking on the small gear wheel icon in the function block, as shown below: The example code below shows how it works.
|
Use the createRectangle function to have the robot draw three rectangles: the first one 12x20, the scond one 6x10, and the third one 3x5. |
Grid Size: S M L | Simple View: | MinView: |
Coord: x-axis y-axis | Grid Lines: x-axis y-axis | |||
Grid: | 12x12 inches | 24x24 inches | 36x36 inches | |
72x72 inches | 96x96 inches | 192x192 inches | ||
1x1 inches | 2x2 inches | Fraction: | ||
xy-Range: | ||||
|
||||
|
||||
Quad: | 1 Quadrant | 4 Quadrants | 1&4 Quadrants | |
Units: | US Customary | Metric | Ruler: |
Labels: |
|
|
|
Font
px
|
|
Tics Lines: |
|
Width
px
|
Hash Lines: |
|
Width
px
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
(
,
in
) in
|
|
![]() |
|
|
|||||||||||
|
|||||||||||