3. Procedures

The previous page described a module. This is usually a substantial chunk of code responsible for a specific task.

A module is broken down internally into smaller tasks called 'Procedures'

A procedure has a specific task to perform, the module needs a collection of procedures in order to fulfill its overall purpose.

Example

The User Interface module is to be designed. It might look like this

Program  'User Interface'
Procedure DisplayGraphics
Begin

------

------
End



Procedure HandleLightPen

Begin

----

----

End





Procedure MenuControl
Begin
 ----
End



Begin
 DisplayGraphics
 HandleLightPen

 MenuControl

End

  

The User Interface module consists of three procedures 'DisplayGraphics', 'HandleLightPen' and 'MenuControl'.

Each procedure has a begin statement of some kind (often just an open curly bracket { ), what this looks like depends on the specific computer language being used. And each procedure will have an end statement of some kind (often a closing curly bracket } ). The main loop of the module is at the bottom which simply calls each procedure in turn. Perhaps the 'Menu Control' procedure would activate other modules.

There are two types of procedures that are described on the next page, the 'subroutine' and the 'function'.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Procedures

 

Copyright © www.teach-ict.com