MUMPS Programming/indirection

From Wikibooks, open books for an open world
Jump to navigation Jump to search

MUMPS allows for self-modifying code and indirection of variables. The @ symbol is used as a prefix to indicate that the variable is actually a pointer to another variable.

EXAMPLE:

> S X=1,Y="X" ; Create the initial two variables, X and Y
> W X ; Send the value of X to the current device
1
> W Y ; Send the value of Y to the current device
X
> W @Y ; Send the value of the pointed-to variable (X) to the current device
1
>


The pointer reference can contain any string that evaluates to a valid variable name, whether a LOCAL or a GLOBAL variable. The pointer reference itself can be either type of variable.

NOTE: This is not the same as code indirection, which is covered under a different article.