Procedures

A procedure is a sequence of blocks or code that is stored under a name, the name of your procedure block. Instead of having to keep putting together the same long sequence of blocks, you can create a procedure and just call the procedure block whenever you want your sequence of blocks to run. In computer science, a procedure also might be called a function or a method.

Blocks:

procedure do

Collects a sequence of blocks together into a group. You can then use the sequence of blocks repeatedly by calling the procedure. If the procedure has arguments, you specify the arguments by using the block's mutator button. If you click the blue plus sign, you can drag additional arguments into the procedure.

When you create a new procedure block, Kodular chooses a unique name automatically. You can click on the name and type to change it. Procedure names in an app must be unique. Kodular will not let you define two procedures in the same app with the same name. You can rename a procedure at any time while you are building the app, by changing the label in the block. Kodular will automatically rename the associated call blocks to match.

When you create a procedure, Kodular automatically generates a call block and places it in the My Definitions drawer. You use the call block to invoke the procedure.

procedure result

Same as a procedure do block, but calling this procedure returns a result.

After creating this procedure, a call block that needs to be plugged in will be created. This is because the result from executing this procedure will be returned in that call block and the value will be passed on to whatever block is connected to the plug.