Microsoft Small Basic

SubRoutines

Modified: 2009/11/28 16:10 by 75.208.65.145 - Uncategorized
Sometimes it's convenient to be able to to refer to other recipes. It programming this is done via a subroutine.

Translating a recipe call is the easiest of them all. Let's say we have a line like

 'draw a square (recipe below) 

First, remove the spaces to create a recipe label, then add () to call it.

 drawASquare() 

Of course it's not enough just to call it, we will also need to define the subroutine later

 'Recipe for drawASquare
 ' do stuff

Here we use the Sub command

 Sub recipeName
    ' do stuff
EndSub 

Then we need to replace the 'recipeName' with the label we created earilier (drawASquare)

 Sub drawASquare
    ' do stuff
EndSub 

Couldn't be easier!

ScrewTurn Wiki version 2.0.35. Some of the icons created by FamFamFam.