Chapter 9: Routine Structure and Execution Flow Control
Chapter 9: Routine Structure and Execution Flow Control
Note to Experienced Programmers
The constructs described in this chapter deal with M language flow control. M provides calling flow control (through the DO command) as well as unconditional branching (GOTO command). However, there are some other aspects of flow control that are different from other languages, including scope of conditional execution and access to local variables. Block structuring is also available. QUIT with a postconditional is used to terminate singleline execution in some cases. Because the M implementation of these features differs from that of other programming languages, it is recommended that this chapter be studied with some care.
In Chapter 8 we learned how to write a command line, making use of the linestart character (either a tab or a space, depending on your implementation). As we will see in this chapter, use of this character also determines whether the M interpreter will execute a command line as soon as it has been entered or store it in a routine that can be saved. When a command line contains a linestart character (either at the beginning of the line or following a label), the line is stored in the routine workspace. When no linestart character is encountered, M executes the command line directly; this mode of execution is referred to as directmode execution.
What is a routine?
In this chapter we introduce the commands that allow a user to execute stored routines using the programming mode of execution.
Copyright Butterworth-Heinemann 1997 under license agreement with Books24x7