Declaration of variables In the simple program above there is no need to declare variables, although as your knowledge of the language increases you will see there is a need for this in most circumstances. If a value has not been assigned to a variable it is assumed that it contains its default value, a 0 if it is numeric or null if it is a string. You should spend time thinking about your variables and ensure that you choose an identifier, or name, that reflects the use to which the variable will be put. eg. dayofweek
or weeklypay
A more complicated example The final program in this section introduces a more advanced feature, the use of subroutines. Again, enter the program and run it to see what happens. PRINT"I will summon the butler procedure." summonbutler PRINT"Yes, bring up some tea and floppy discs..." END SUB summonbutler PRINT"you rang sir?" END SUB
This is a somewhat trivial program, but it introduces another feature of QuickBASIC, the SUBROUTINE. A subroutine is simply a little program within the main program that performs some function. In this case the subroutine simply prints You rang sir?
on the screen. Subroutines can be as complex as the main section of the program and can contain there own declarations and even their own subroutines. The main use of subroutines is to break down a program into smaller more manageable sections. They are particularly useful when you wish to perform the same function more than once as they can save a lot of typing. Subroutines and their uses will be described in more detail later.