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

ELSE

M[UMPS] by Example

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

The most common If-Then-Else construction is:
If X=4 Set A=5
Else  Set A=6

But
If X=4 Do SUB
Else  Quit

may produce an unexpected result if the program assumes that the value of $Test does not change within the subroutine SUB.

If the code in the above example was intended as an If-Then-Else construction, then it would be better to write it as:
Quit:X'=4  Do SUB

Open DEVICE::20 Else  Write "..." Quit
Don’t process any data when resources cannot be allocated.

Lock +^ABC:20 Else  Write "..." Quit
Don’t update while someone else is editing

If VAR=VALUE Lock ^NAME:TIMEOUT Set X=1
Else  Set X=2

In this case... it depends. In the case where the values of VAR and VALUE are not equal, local variable X will be set to 2, but in the case whare those two variables do have the same value, the value of $Test may become false if the time-out expires, in which case the Else command will also allow X to be set to 2.

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-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.

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 15-Nov-2023, 14:42:33.

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