Download SQA Higher Computing Unit 2: Software Development
Transcript
6.4. PROGRAM STRUCTURE ' , ) ' , Code 5 The program area contains the following: • A general area: this area is public and variables declared here will be ’seen’ by all parts of the program. Global variables should be avoided wherever possible. More on this will be discussed later under the term scope. • A sub procedure cmd click( ): this contains the main program code that will be initiated in the event of a mouse click, for example. Within this code there are further declarations local to the sub procedure. The declarations are: – Constants: any fixed values which will stay constant throughout the program are declared here; – Variables: variables other than global variables that are going to be used in the program are declared here. – Sub procedures: any subprocedures required by the program are declared after the main sub procedure. These are described more fully later on. – Functions: - any functions the program will use are also declared here. These are described more fully later on. The input may be from a variety of devices, not just the keyboard. A disk is an input device when the computer reads data (including programs) from it. The program may also receive data internally during program execution. The calculation is the heart of the program. The input data is transformed to the output data. This, in short, is all that a computer does. The output phase is less straightforward! There is no screen output in Visual BASIC, only windows called forms. Output can also be directed to a file, printer or disc. You will see example output methods in the program exemplars. © H ERIOT-WATT U NIVERSITY 95