O'Reilly logo

Rexx Programmer's Reference by Howard Fosdick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Subroutines, Functions, and Modularity

Overview

Rexx fully supports structured programming. It encourages modularity — breaking up large, complex programs into a set of small, simple, interacting components or pieces. These components feature well-defined interfaces that render their interaction clear. Modularity underlies good program structure. Modularity means more easily understood and maintained programs than ill-designed "spaghetti" code, which can quickly become unmaintainable on large programming projects. Structured programming practices and modularity together reduce error rates and produce more reliable code.

Rexx provides the full range of techniques to invoke other programs and to create subroutines and functions. The basic concept is that there should be ways to link together any code you create, buy, or reuse. This is one of the fundamental advantages to using a "glue" language like Rexx.

With Rexx, you can develop large, modular programs that invoke routines written in Rexx or other languages, which issue operating system commands and utilize functions packaged in external function libraries. This chapter describes the basic ways in which one writes modular Rexx programs.

This chapter investigates how to write internal subroutines and functions, and how to call them from within the main program. Passing arguments or values into subroutines is an important issue, as is the ability to pass changed values back to the calling program. Variable scoping refers to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required