Circular References & Conversions

A common desire in templates is to create a set of computations that are inter-related, such as conversions. A typical conversion template shows a series of measurements. Entering any one will calculate all of the others.

onEnter helps streamline this process, making all variables equate back to one key variable. This makes computation more accurate and makes conversion templates easier to read. onEnter is included in the Settings block:

onEnter:key,dependent1,dependent2,dependent3 ::

All rows then, except the key row, uses a conversion equation definition based on the key. This equation must always be in the form "current = key * factor" (no quotes) where current is the variable for the current row, key is the variable for the key's row and factor is your conversion. (Could also use divide or a more sophisticated formula.) An example:

        [settings_begin]
        onEnter:gal,qts,pts ::
        [settings_end]

        Gallons "" gal ::
        Quarts "" noequals qts:qts=gal*4 ::
        Pints "" noequals pts:pts=gal*8

How It Works

onEnter works by taking the entered row and using it to calculate the key variable. In the example above, entering 10 for qts will use the solver to calculate the key variable, gal. Once gal is known then auto calculation kicks in to calculate pts. noequals is used since entering one will automatically calculate the others without the need to select an equals button.

Additional Information

All other elements of the row are also available. For instance, you can use precision settings, chain variables to link to additional computations, and keywords as appropriate.

Finally, you can have multiple onEnter statements in a template. While dependent variables must only be used in one onEnter statement, key can be used as a key in another onEnter statement if desired.