Popis: |
This chapter discusses parameter lists and libraries observed in Turbo BASIC. A subroutine can have a list of variables, called a parameter list, appended to its name; such parameter lists can be used to pass information back and forth between a subroutine and the main and other routines. The communication of information between a subroutine and its calling routine can be done using the SHARED statement or parameter lists. In smaller programs, with few subroutines, the SHARED statement provides an easy method for communicating information. Variable names in the SHARED statement need to be the same as the variable names in the calling routine. In longer, more complex programs, parameter passing provides greater control over the communication of information between a subroutine and its calling routine. In communicating information with parameters, the list of variables appended to the name in the SUB statement is the parameter list of the subroutine. Subroutines and functions that frequently are used in a variety of programs can be saved separately in a library. Such libraries can be included in any program that is written. In writing programs, a number of standard routines maybe developed that are used frequently in many different programs. Such routines can be gathered together on diskette in what might be called a library. The naming scheme used in a program can be independent of the naming scheme used when creating a subroutine library. |