Omni Systems, Inc. |  | Mif2Go User's Guide, Version 55 |  |  |  |  |

> 28 Working with macros > 28.6 Using expressions in macros > 28.6.7 Using indirection in expressions

### 28.6.7 Using indirection in expressions

Suppose you assign a variable to another variable, as follows:

<$$myvar = $$other>

Then, if you subsequently use:

<$$myvar>

you get whatever contents the variable named $$other had at the time you assigned it to the variable named $$myvar. Suppose you specified the original assignment like this:

<$$myvar = "$$other">

Then, if you subsequently use:

<$$myvar>

all you get is the literal string “$$other”. If instead you use:

<*$$myvar>

you get the current contents of the variable $$other (but if there were no variable named $$other, you would get just the literal string “$$other”).

The same thing works through multiple layers. If you use this series of assignments:

<$$myvar = "$$other">

<$$other = "$$whatever">

<$$whatever = "here">

then, subsequently, the contents of <*$$myvar> is “here”, which is the same as the contents of <*$$other>, or of <$$whatever>, or even of <*$$whatever>.

Now if you set:

<$$other = "something">

then:

<$$myvar> gives: $$other

<*$$myvar> gives: something

If next you set:

<*$$myvar = "something else">

then:

<$$other> gives: something else

<$$myvar> gives: $$other

<*$$myvar> gives: something else

If finally you set:

<$$other = "$$myvar">

then (oops!):

<$$other> gives: nothing

Runaway-prevention limit

However, a built-in circular-reference counter saves you from the natural consequences of this last foolish assignment. The counter prevents indirection through more than 128 levels.

The top-level variable is like an envelope that can contain more nested envelopes; you continue opening them until you get to the letter (the contents). You can use indirection to recurse, to process variables and expressions, and so forth, down to a simple value, through whatever layers that takes.

> 28 Working with macros > 28.6 Using expressions in macros > 28.6.7 Using indirection in expressions

| Mif2Go User's Guide: 28.6.6 Using list variables in expressions |  | Mif2Go User's Guide: 28.6.8 Removing spaces from strings: an example |