Functions

Introduction
A [|function] is a subprogram or subroutine of the main program and is developed to carry out a specific task.

A function returns a value.

Real Basic comes with a range of pre-built functions in its [|library]. For example, function Round takes as a [|parameter] a number of type Double and returns a rounded whole number of type Integer. e.g. Round (1.4) returns the value 1 Round (1.6) returns the value 2

The benefits of a function (or procedure) are that:
 * The code need only be written once
 * The code can be reused many times in a program
 * The programmer who is accessing the function doesn't need to how the function works. They only need to know the parameters that it expects, and the values it returns

As an example, consider a programmer reading the specification of a project. It's clear that in different parts of the program, there will be a requirement to find the square of a number. Rather than writing the code to square the numbers over and over again, the programmer should consider writing a function called SquareNumber which takes a number as a parameter and returns the square of the number.

Task 1
Spaceship

Task 2
Get Result