Skip to main content

Procedure

Defines a grouping of commands to do a particular function. Select "name" and type over it to rename the procedure.

Procedure block

Description

The Procedure block defines a grouping of commands to do a particular function. Select "name" and type over it to rename the procedure. This is a code block part of the Procedures drawer.

Usage

Defines a grouping of commands to do a particular function. Select "name" and type over it to rename the procedure.

Syntax

Inputs in this block:

  • In the "name" box, enter a name for the procedure
  • Choose the desired return statement from the drop down menu

Example

In this version of the snake game, the direction the snake moves is determined by which key is typed. This set of instructions is executed while forever is toggled using the procedure 'read keyboard input.'

Procedure example code

Notes

Procedures help organize code into reusable sections, making programs more modular and easier to maintain. They can accept parameters and optionally return values.

  • Call - Execute a defined procedure
  • Call (returns) - Execute a procedure and retrieve its return value
  • Parameter - Use parameter values within a procedure
  • Return Early - Exit a procedure early and optionally return a value