Advanced Templates

Advanced templates offer ultimate flexibility in creating templates. You create advanced templates with a simple meta language that defines each row of the template.

This page acts as a quick overview and introduction. Subsequent pages offer more detail on each of the topics covered here.

Basic Structure

Let us start by looking at the structure of a number row (this is the simplest case):

"Label" "Default" variable:equation ::

"Label": template's label in quote marks (details here)
"Default": row's default value in quote marks. A default value is excluded if it's a value you would expect a template user to enter; otherwise give it a value. (details here)
variable: reference name for the row (details here)
colon: separates the variable from equation
equation: formula to calculate (details here)
double-colon: ends a row

If there is no equation then colon and equation are not included. If it is the last row of the template then double-colon is optional.

Basic Example

This template contains three rows where entries in the first and second row result in a computation in the third. The calculation in the third row adds the first row and the second row together. All three rows are real numbers.

      "First Row" "" a ::
      "Second Row" "" b ::
      "Answer" "" c:b+a

First Row
The first row has a label of "First Row" (with quotes as it is multiple words) and no default value "". The variable is 'a' (no quotes). Since there is no equation neither the colon nor equation is added. Finally the double-colon indicates the end of the row.

Second Row
The second row has a label of "Second Row" (with quotes as it is multiple words) and no default value "". The variable is 'b' (no quotes). Since there is no equation neither the colon nor equation is added. Finally the double-colon indicates the end of the row.

Third Row
The third row has a label of "Answer" (quotes are optional as it is a single word) and no default value "". The variable is 'c' (no quotes). This row will be calculated so a colon separates the variable from the equation. The equation is 'b+a' (no quotes). The same equation could be 'c=b+a' but 'c=' is not required. See Equations section for details. Notice that there is no double-colon to end the row. Since this is the last row it is optional.

Moving From Simple to Advanced Templates

All simple templates are transformed into advanced templates when prepared for display. For example, the equation a=b+c would be transformed internally to look like this advanced template:

      "a" "" a:a=b+c ::
      "b" "" b:a=b+c ::
      "c" "" c:a=b+c ::
      ::
      decSetting ::

powerOne uses the variable name for the label and replicates the same expression in each row. In addition a separator and the special row decSetting is added at the bottom. decSetting gives the template user the ability to change the number of decimal places displayed in all rows.

Internally, when you choose one of the rows to calculate (or powerOne figures out which one to calculate), it plugs in the values it knows and calculates the one it doesn't. If it knows b and c then it will directly calculate a. If it knows a and c instead, for instance, then it solves for (iterates until it finds an answer for) b. Technically a isn't needed for the first row because we are directly calculating a. So if we were writing the template as an advanced template you could do this instead, leaving off the "a=" in the first row:

      "a" "" a:b+c ::
      "b" "" b:a=b+c ::
      "c" "" c:a=b+c ::
      ::
      decSetting ::

Finally, solving takes time and may or may not be precise. Because it is iterative, it derives the closest answer it can. Most of the time this is plenty precise but if you want to be certain, you can mathematically solve for each expression yourself. The resulting template would look like this:

      "a" "" a:b+c ::
      "b" "" b:a-c ::
      "c" "" c:a-b ::
      ::
      decSetting ::

The bottom line: there is no right way to do this. All of the examples above will get you to the same place.

Data Types

Each data type is defined in detail on the following pages. In addition, advanced topics are included in the Auto Calculate, Chaining & Defaults section and examples in the Examples section.