M Programming: A Comprehensive Guide

Chapter 10: Program Structure

Chapter 10: Program Structure
Note to Experienced Programmers
This chapter expands on execution control flow introduced in Chapter 9 by describing interroutine flow control. Execution flow control is quite similar to comparable constructs in other languages. The exercise section introduces the concept of saving routines and using nonstandard system editors.
Routines are collections of command lines that are stored by the M interpreter in such a way that they can be retrieved and used as a unit. Routines are given names, and by convention, the first line of each routine contains its name, the author's name or initials, the date of creation, and a brief description.
The final step in creating a computer solution to an information-handling problem is to link routines together so as to form packages, which are collections of routines that together fulfill a common purpose. By use of the DO/QUIT combination, it is possible to create a modular solution involving a series of routines, each solving a limited portion of a problem. GOTO also may be used for transfer of control between routines, though it offers less structured flow control between routines.
DO/QUIT and GOTO commands used with routines
There are two ways to access routines that have been previously stored. These involve the use of the DO and GOTO commands described in the previous chapter, with one additional feature: the name of a routine is preceded by a caret ( ^ ), which prints on some terminals as an uparrow.
To illustrate the...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Computer Numerical Control Software (CNC)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.