Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples
Left Hand Pointer

$TEST

M[UMPS] by Example

Right Hand Pointer

Introduced in the 1977 ANSI M[UMPS] language standard.

The value of this variable identifies whether or not the most recent occurrence of one of the following commands was successful: If (always), Read (with time-out), Open (with time-out) or Lock (with time-out).

If DEVICE'=PRINTER Open DEVICE::20
Else Open PRINTER:120

When the values of the variables DEVICE and PRINTER are unequal and opening the device indicated by DEVICE can not be realized within 20 seconds, the value of $Test becomes 0 (false) and the device indicated by PRINTER will be opened as soon as it is available. Note that the ::20 specifies a timeout and the :120 specifies an implementation-specific deviceparameter.
When the values of DEVICE and PRINTER are equal, the device indicated by PRINTER will be opened as soon as it is available.
Note that the action taken after the Else command depends on the outcome of the If command, but also on the outcome of the timeout when it is processed.

Additions in a future M[UMPS] language standard:

The special variable $Test may occur as an argument of the New command.

 Set T="$TEST should be "
 If REASON Do SUB1 Write !,T,"1:",$Test,"."
 Else  Do SUB2 Write !,T,"1: ",$Test,"."
 Quit
SUB1 Write !,T,"1: ",$Test,"."
 New $Test
 If 0 ; Force $TEST to a new value
 Quit
SUB2 Write !,T,"0: ",$Test,"."
 If 1 ; Force $TEST to a new value
 Quit

The initial value of $Test is 0 (false).

The THen command may be used to stack the value of $Test "until the end of the current line".

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.

Button for 1977 Button for 1984 Button for 1990 Button for 1995 Button for MDC Button for notes Button for examples

Copyright © Standard Documents; 1977-2017 MUMPS Development Committee;
Copyright © Examples: 1995-2017 Ed de Moel;
Copyright © Annotations: 2003-2017 Jacquard Systems Research.

The information in this page is NOT authoritative and subject to be modified at any moment.
Please consult the appropriate (draft) language standard for an authoritative definition.

Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.

This page most recently updated on 13-Sep-2014, 08:18:38 .

For comments, contact Ed de Moel (demoel@jacquardsystems.com)