Programming Statements
Statements That Define and Execute Modules
- Defining and Executing a Module
- Understanding Symbol Tables
- Modules with No Arguments
- Modules with Arguments
- Passing Arguments by Using Keyword-Value Pairs
- Defining Function Modules
- Using the GLOBAL Clause
- Modules with Optional and Default Arguments
- Nesting Module Definitions
- Calling a Module from Another Module
- Understanding Argument Passing
- Storing and Loading Modules
Modules are used for two purposes:
to create a user-defined subroutine or function. That is, you can define a group of statements that can be called from anywhere in the program.
to define variables that are local to the module. That is, you can create a separate environment with its own symbol table (see Understanding Symbol Tables).
A module always begins with a START statement and ends with a FINISH statement. A module is either a function or a subroutine. When a module returns a single parameter, it is called a function. A function is invoked by its name in an assignment statement. Otherwise, a module is a subroutine. You can execute a subroutine by using either the RUN statement or the CALL statement.