Approved for inclusion in a future ANSI M[UMPS] Language standard.
The command THEN stacks the value of special variable $TEST. This value will be "popped" off the stack when execution moves to a different line of code (either through a GOTO command, or when the end of the current line is reached).
Assume that the code segment below is executed.
FOR A=1,0 DO . IF A WRITE !,"TRUE 1" IF 0 . ELSE WRITE !,"FALSE 1" . IF A THEN WRITE !,"TRUE 2" IF 0 . ELSE WRITE !,"FALSE 2" . QUIT
At the first iteration of the FOR loop, the value of A is true (1). The first IF command will cause the text "TRUE 1" to be written, and the second IF command on that line will cause the value of special variable $TEST to be set to 0 (false). As a result, on the next line, the ELSE command will cause the text "FALSE 1" to be written.
The next IF command will cause the text "TRUE 2" to be written, and this time, the THEN command will stack the value of $TEST (which is at this point equal to 1). After this, the second IF command on that line will cause the value of special variable $TEST to be set to 0 (false). At this point, the end of the line is reached, and the value of $TEST will be popped off the stack, setting it back to 1 (true). As a result, on the next line, the ELSE command will cause the rest of that line to be ignored.
At the second iteration of the FOR loop, the value of A is false (0). The first IF command will cause the rest of that line to be ignored, and, on the next line, the ELSE command will cause the text "FALSE 1" to be written.
The next IF command will also cause the rest of that line to be ignored, and, on the next line, the ELSE command will cause the text "FALSE 2" to be written.
This document is © Ed de Moel, 1995-2005.
It is part of a book by Ed de Moel that is published under
the title "M[UMPS] by Example" (ISBN 0-918118-42-5).
Printed copies of the book are no longer available.
This document describes the various commands that are defined in the M[UMPS] language standard (ANSI X11.1, ISO 11756).
The information in this document is NOT authoritative
and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an
authoritative definition.
In this document, information is included that will
appear in
future standards.
The MDC cannot guarantee that these 'next'
standards will indeed appear.